Skip to content

Instantly share code, notes, and snippets.

@flovv
Last active January 17, 2016 15:08
Show Gist options
  • Save flovv/461dc6a505b21eda10a9 to your computer and use it in GitHub Desktop.
Save flovv/461dc6a505b21eda10a9 to your computer and use it in GitHub Desktop.
Soccer Betting Odds
require(rvest)
require(stringr)
url <- "http://www.wettfreunde.net/bundesliga-absteiger-wetten/"
# Darmstadt
1/2.25
1/2.3
mv <- html(url)
tab <- mv %>% html_table
tab <- tab[[1]]
tab <- tab[4:nrow(tab),]
colnames(tab) <- c("Team", "mybet", "tipico", "bet365", "betsafe", "sportingbet")
tab$mybet<- 1/as.numeric(str_replace_all(tab$mybet, ",", "."))
tab$tipico<- 1/as.numeric(str_replace_all(tab$tipico, ",", "."))
tab$bet365<- 1/as.numeric(str_replace_all(tab$bet365, ",", "."))
tab$betsafe<- 1/as.numeric(str_replace_all(tab$betsafe, ",", "."))
#########
sum(tab$mybet, na.rm=T)
sum(tab$tipico, na.rm=T)
sum(tab$bet365, na.rm=T)
sum(tab$betsafe, na.rm=T)
##########################
########## normalizse odds!
tab$mybet<- tab$mybet / sum(tab$mybet, na.rm=T) * 2
tab$tipico<- tab$tipico / sum(tab$tipico, na.rm=T) * 2
tab$bet365<- tab$bet365 / sum(tab$bet365, na.rm=T) * 2
tab$betsafe<- tab$betsafe / sum(tab$betsafe, na.rm=T) * 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment