Motion charts in R

Formatting a motion chart in Google Visualization is as hellish as it’s surprising how simple R makes it. One more reason to learn this underrated language. To create this motion chart, I downloaded the data from here (as CSV) and keyed in the following lines in RStudio:

[code language=”r”]

emissions <- read.csv("–path to file–/emissions.csv", header=T)
install.packages("googleVis")
library("googleVis)
emissions_Motion = gvisMotionChart(emissions, idvar="Country", timevar="Year")
plot(emissions_Motion)
cat(emissions_Motion$html$chart, file="emissions.html")

[/code]

That’s it.