Maps with R, part… n+1

[This article was first published on Freakonometrics - Tag - R-english, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Following the idea posted on James Cheshire’s blog (here), I have tried to play a little bit with R and Google. And it works ! Consider for instance life expectancy at birth (that can be found – and downloaded – here). Using the following code, it is possible to generate an R graph in a web page,

install.packages("googleVis")
library(googleVis)
input=read.csv("UNdata_Export_20110111_101634359.txt",
      sep=";",header=TRUE)
Map<- data.frame(input$Country.or.Area, input$Value)
names(Map)<- c("Country", "Age")
Geo=gvisGeoMap(Map, locationvar="Country", numvar="Age",
options=list(height=350, dataMode='regions'))
plot(Geo)
XX(ok, there are still some problems with some countries - e.g. Russia and the US - but it should not be that difficult to fix). Thanks James, this is awesome !

To leave a comment for the author, please follow the link and comment on their blog: Freakonometrics - Tag - R-english.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)