sofa_calendar.R

library(sofascoreR)
library(gigweb)

data(tournaments)

data(atp_calendar)

# Assign uniqueId

atp <- tournaments %>% filter(tour == "atp")

atp_calendar$uniqueId <- sapply(atp_calendar$flashscore.url, function(x) {
	id <- grep(x, ignore = T, atp$links)
	if(length(id) == 1)
		atp$uniqueId[id]
	else
		NA
})

atp_calendar$uniqueId[atp_calendar$flashscore.url == "auckland"] <- 2481
atp_calendar$uniqueId[atp_calendar$flashscore.url == "marseille"] <- 2486
atp_calendar$uniqueId[atp_calendar$flashscore.url == "munich"] <- 2491
atp_calendar$uniqueId[atp_calendar$flashscore.url == "madrid"] <- 2607
atp_calendar$uniqueId[atp_calendar$flashscore.url == "lyon"] <- 2498
atp_calendar$uniqueId[atp_calendar$flashscore.url == "halle"] <- 2493
atp_calendar$uniqueId[atp_calendar$flashscore.url == "kitzbuhel"] <- 2501
atp_calendar$uniqueId[atp_calendar$flashscore.url == "st-petersburg"] <- 2499
atp_calendar$uniqueId[atp_calendar$flashscore.url == "metz"] <- 2496




data(wta_calendar)

# Assign uniqueId

wta <- tournaments %>% filter(tour == "wta")

wta_calendar$uniqueId <- sapply(wta_calendar$flashscore.url, function(x) {
	id <- grep(x, ignore = T, wta$links)
	if(length(id) == 1)
		wta$uniqueId[id]
	else
		NA
})

wta_calendar$uniqueId[wta_calendar$flashscore.url == "new-haven"] <- 2602
wta_calendar$uniqueId[wta_calendar$flashscore.url == "moscow"] <- 2550

save(atp_calendar, file = "~/Software/sofascoreR/data/atp_calendar.RData")
save(wta_calendar, file = "~/Software/sofascoreR/data/wta_calendar.RData")
GIGTennis/sofascoreR documentation built on Oct. 10, 2018, 5:22 p.m.