Skip to content

Instantly share code, notes, and snippets.

@stephlocke stephlocke/sqlbitsRcode.R
Last active Aug 29, 2015

Embed
What would you like to do?
Initial R code for looking at sqlbits tracks
# get html from url
library(RCurl)
library(XML)
library(data.table)
library(ggplot2)
url <- "http://sqlbits.com/information/PublicSessions.aspx"
src<-getURL(url)
# transform html
h.s<-htmlParse(src)
#extract session data
sessions<-data.table(session=xpathSApply(h.s,"//h4",xmlValue),
presenter=xpathSApply(h.s,"//a[@id='SpeakerName']",xmlValue),
Level=xpathSApply(h.s,"//div[@style='float: right; font-weight: bold; margin-left: 1em']",xmlValue),
Track=xpathSApply(h.s,"//div[@style='float: right; font-weight: bold']",xmlValue))
#clean session data
sessions[,session:=gsub(" ","",gsub("\r\n","", session))][
,Level:=gsub(" ","",gsub("\r\n","", Level))][
,Track:=gsub(" ","",gsub("\r\n","", Track))]
#start charting for kicks
ggplot(sessions,aes(x=Track,y=..count..,fill=Level, group=Level))+
geom_histogram()+
theme_minimal()+
scale_fill_brewer()+
labs(title="Submitted sessions")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.