Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created February 10, 2014 00:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramnathv/4b810adae24f168d4330 to your computer and use it in GitHub Desktop.
Save ramnathv/4b810adae24f168d4330 to your computer and use it in GitHub Desktop.
Olympic Medals with rCharts
library(XML); library(reshape2)
options(stringsAsFactors = F)
standings = readHTMLTable('http://www.sochi2014.com/en/medal-standings', which = 1,
colClasses = c('character', 'character', rep('numeric', 4))
)
standings_m = melt(subset(standings, Total > 0), id = c('Country', 'Rank'),
variable.name = 'Medal', value.name = 'Count'
)
library(rCharts)
n1 <- nPlot(Count ~ Country,
data = subset(standings_m, as.character(Medal) != "Total"),
type = 'multiBarHorizontalChart',
group = 'Medal'
)
n1$chart(
color = c('#C98910', '#A8A8A8', '#965A38'),
stacked = TRUE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment