2019-05-15 19:56:07 +02:00
|
|
|
#
|
|
|
|
# RESULTS
|
|
|
|
#
|
2019-05-15 00:27:04 +02:00
|
|
|
|
|
|
|
# Results with pagination
|
2019-05-15 22:28:34 +02:00
|
|
|
getFilteredResults <- function(input) {
|
|
|
|
getMatchesList(football_data, input$first_team, input$second_team) %>%
|
|
|
|
filterByDate(as_date(input$date_from), as_date(input$date_to))
|
|
|
|
}
|
|
|
|
|
2019-05-15 00:27:04 +02:00
|
|
|
resultsWithPagination <- function(input, output) {
|
|
|
|
output$results_pagination <- DT::renderDataTable(
|
2019-05-15 22:28:34 +02:00
|
|
|
getFilteredResults(input),
|
2019-05-15 00:27:04 +02:00
|
|
|
extensions = 'Buttons',
|
|
|
|
options = list(
|
|
|
|
lengthMenu = list(c(5, 10, -1), c('5', '10', 'All')),
|
|
|
|
pageLength = 10,
|
|
|
|
searching = FALSE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Balance
|
2019-05-15 22:28:34 +02:00
|
|
|
getBalanceData <- function(input) {
|
|
|
|
getBalance(getFilteredResults(input))
|
|
|
|
}
|
|
|
|
|
2019-05-15 00:27:04 +02:00
|
|
|
balanceBetweenTeams <- function(input, output) {
|
|
|
|
output$balance <- renderPlot({
|
|
|
|
barplot(
|
2019-05-15 22:28:34 +02:00
|
|
|
getBalanceData(input)$n,
|
2019-05-15 00:27:04 +02:00
|
|
|
main = "Balance between teams",
|
|
|
|
col = rainbow(3),
|
2019-05-15 22:28:34 +02:00
|
|
|
names.arg = getBalanceData(input)$winner
|
2019-05-15 00:27:04 +02:00
|
|
|
)
|
|
|
|
})
|
2019-05-15 19:56:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Balance percentage
|
|
|
|
balancePercentage <- function(input, output) {
|
|
|
|
output$balancePieChart <- renderPlot({
|
|
|
|
pie(
|
|
|
|
getBalancePercentage(
|
2019-05-15 22:28:34 +02:00
|
|
|
getBalanceData(input)
|
2019-05-15 19:56:07 +02:00
|
|
|
)$percentage,
|
|
|
|
main = "Match balance (percentage)",
|
|
|
|
labels = getBalancePercentage(
|
2019-05-15 22:28:34 +02:00
|
|
|
getBalanceData(input)
|
2019-05-15 19:56:07 +02:00
|
|
|
)$winner,
|
|
|
|
col = rainbow(3)
|
|
|
|
)
|
|
|
|
})
|
2019-05-15 00:27:04 +02:00
|
|
|
}
|