Sochi 2014, R, D3.js

February 18, 2014
By

(This article was first published on Learning Data Science , and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, 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...

Comments are closed.

Sponsors

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)