Summary statistics added

This commit is contained in:
Jakub Wajs 2019-06-14 23:50:49 +02:00
parent 70c70cd7f8
commit 6c4b99c4c7
2 changed files with 21 additions and 2 deletions

View File

@ -86,6 +86,7 @@ balancePercentage <- function(input, output) {
# Summary statistics # Summary statistics
summaryStatistics <- function(input, output) { summaryStatistics <- function(input, output) {
output$summary_statistics <- renderTable( output$summary_statistics <- renderTable(
goalsScored(getFilteredResultsForTeam(input), input$team) goalsOverallSummary(getFilteredResultsForTeam(input), input$team),
rownames = TRUE
) )
} }

View File

@ -34,7 +34,7 @@ goalsLost <- function(matches, team) {
home_goals, away_goals, home_goals + away_goals home_goals, away_goals, home_goals + away_goals
) )
return(goals_scored) return(goals_lost)
} }
matchesNumber <- function(matches, team) { matchesNumber <- function(matches, team) {
@ -78,3 +78,21 @@ avgGoalsLost <- function(matches, team) {
return(avg_goals_lost) return(avg_goals_lost)
} }
# Summary
goalsOverallSummary <- function(matches, team) {
scored <- goalsScored(matches, team)
scoredAvg <- avgGoalsScored(matches, team)
lost <- goalsLost(matches, team)
lostAvg <- avgGoalsLost(matches, team)
goalsOverall <- data.frame(
"Home" = c(scored$home_goals, lost$home_goals, scoredAvg$home_goals_avg, lostAvg$home_goals_avg),
"Away" = c(scored$away_goals, lost$away_goals, scoredAvg$away_goals_avg, lostAvg$away_goals_avg),
"Overall" = c(scored$overall, lost$overall, scoredAvg$overall_avg, lostAvg$overall_avg),
stringsAsFactors = FALSE
)
row.names(goalsOverall) <- c("Scored","Lost", "Scored Avg", "Lost Avg")
return(goalsOverall)
}