Last active
July 18, 2023 01:43
-
-
Save stephlocke/9784217 to your computer and use it in GitHub Desktop.
Initial R code for looking at sqlbits tracks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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