Maps with R, part… n+1

January 11, 2011

(This article was first published on Freakonometrics - Tag - R-english, and kindly contributed to R-bloggers)

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,

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'))

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 his blog: Freakonometrics - Tag - R-english. offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , ,

Comments are closed.