Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Last active July 18, 2023 01:43
Show Gist options
  • Save stephlocke/9784217 to your computer and use it in GitHub Desktop.
Save stephlocke/9784217 to your computer and use it in GitHub Desktop.
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