Maps with R, part... n+1
By arthur charpentier on Tuesday, January 11 2011, 10:34 - Informatique / R - Permalink
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)
(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 !






Comments
For US one should enter "United States" and for Russia "RU"
Best regards.
ANSWER: thanks, I will post a comment with a revised code....