About Me

My photo
Just wasting time sharing knowledge about, Big Data and Analytics

Feb 18, 2014

Sochi 2014, R, D3.js

Ramnath design rCharts wich combine the powerful of open source R and D3.js.
It give very pretty plots. Here is some code, using package XML to collect the data from http://www.sochi2014.com/fr/classement-des-medailles and plot a kind of sankey diagram with rCharts

@Ramnath wrote this :
https://gist.github.com/ramnathv/4b810adae24f168d4330 and the result look like :

Plot with Open source R and rCharts library




















I wrote a piece of code to create a sankey diagram and the result look like we see below

> mm = subset(meltP,select=c(Country, Medal, Count))
> colnames(mm) <- c("target","source","value")
> sankeyPlot <- rCharts$new()
> #We need to tell R where the Sankey library is.
> #I  put it as a subdirectory to my current working directory (.)
> sankeyPlot$setLib('rCharts_d3_sankey-gh-pages')
> #We also need to point to an HTML template page
> sankeyPlot$setTemplate(script = "rCharts_d3_sankey-gh-pages/layouts/chart.html")
> sankeyPlot$set(
+   data = mm,
+   nodeWidth = 15,
+   nodePadding = 10,
+   layout = 32,
+   width = 900,
+   height = 600
+ )