TPD-InternationalFootballRe.../Server/Results.R

53 lines
1.2 KiB
R
Raw Normal View History

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