Pivot Tables in R with melt and cast

If you are making the transition from Excel to R and still can’t figure out how to quickly obtain pivot tables like Excel has, this article is for you!

Actually it is pretty easy to produce Pivot Tables in R. All you need is a package called reshape by Hadley Wickham (yes, the same prolific author of plyr and ggplot2) and some understanding of how reshape “thinks” and works.

Continue Reading

World population infographic with R

R is not just for statistical analysis and data mining, it can also be employed to prepare nice infographics. Here is a quick example of infographic with R.

With few lines of R code we can create, starting from commonly available data, an infographic showing the relative magnitude of the population for the different countries around the world, with the country name placed on the country centroid (like it would be on a map) and the font size proportional to the population size. Simple but impactful!

Continue Reading

Interactive map of world population with R

Recently I have been experimenting with R’s data visualization capabilities and I wanted to test how the maps plotted with rworldmap could be made interactive through the manipulate package, part of RStudio. Interactivity can add a lot to our understanding of complex data sets, where variations happens along multiple dimensions. To get inspired on the topic you can watch this great Ted Talk  by Hans Rosling: Stats that reshape your world-view.

Continue Reading