Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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