diff --git a/Server/Results.R b/Server/Results.R index 581a727..7cf66b1 100644 --- a/Server/Results.R +++ b/Server/Results.R @@ -86,6 +86,7 @@ balancePercentage <- function(input, output) { # Summary statistics summaryStatistics <- function(input, output) { output$summary_statistics <- renderTable( - goalsScored(getFilteredResultsForTeam(input), input$team) + goalsOverallSummary(getFilteredResultsForTeam(input), input$team), + rownames = TRUE ) } \ No newline at end of file diff --git a/Server/SummaryStatistics.R b/Server/SummaryStatistics.R index 181a5c7..ee77e18 100644 --- a/Server/SummaryStatistics.R +++ b/Server/SummaryStatistics.R @@ -34,7 +34,7 @@ goalsLost <- function(matches, team) { home_goals, away_goals, home_goals + away_goals ) - return(goals_scored) + return(goals_lost) } matchesNumber <- function(matches, team) { @@ -77,4 +77,22 @@ avgGoalsLost <- function(matches, team) { ) 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) } \ No newline at end of file