2019-05-15 19:56:07 +02:00
|
|
|
#
|
|
|
|
# DATA PROCESSING
|
|
|
|
#
|
|
|
|
|
2019-05-15 22:28:34 +02:00
|
|
|
# Get matches
|
|
|
|
getMatchesList <- function(matchesData, first_team, second_team) {
|
|
|
|
return(
|
|
|
|
matchesData %>%
|
|
|
|
filter(home_team %in% c(first_team, second_team)
|
|
|
|
& away_team %in% c(first_team, second_team))
|
|
|
|
)
|
2019-05-15 19:56:07 +02:00
|
|
|
}
|
|
|
|
|
2019-05-15 22:28:34 +02:00
|
|
|
# Mathes filters
|
|
|
|
filterByDate <- function(matchesData, dateFrom, dateTo) {
|
|
|
|
return(
|
|
|
|
matchesData %>%
|
|
|
|
filter(as_date(date) >= dateFrom & as_date(date) <= dateTo)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get balance
|
2019-05-15 19:56:07 +02:00
|
|
|
getBalance <- function(football_data) {
|
|
|
|
balance <- football_data %>%
|
|
|
|
count(winner, sort = TRUE)
|
|
|
|
return(balance)
|
|
|
|
}
|
|
|
|
|
|
|
|
getBalancePercentage <- function(balance) {
|
|
|
|
balancePerc <- balance %>%
|
2019-05-16 00:37:48 +02:00
|
|
|
mutate(percentage = n/sum(.$n))
|
2019-05-15 19:56:07 +02:00
|
|
|
}
|