Sochi 2014, R, D3.js

[This article was first published on Learning Data Science , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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

To leave a comment for the author, please follow the link and comment on their blog: Learning Data Science .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)