#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
# Rely on the 'WorldPhones' dataset in the datasets
# package (which generally comes preloaded).
library(ggplot2, quietly = TRUE)
library(dplyr, quietly = TRUE)
library(rsconnect, quietly = TRUE)
#rsconnect::setAccountInfo(name='ferris',
# token='C6F6F60D9DEA870CD88091DAD009D736',
# secret='SECRET')
#rsconnect::deployApp("/Users/andrewferris/Documents/sufc1863/sufc_dashboard")
player_file <- read.csv("player_table_flat_file.csv")
# Define a server for the Shiny app
function(input, output, session) {
# Fill in the spot we created for a plot
output$tacklePlot <- renderPlot({
# Make Tackles Made table
tackle_made_table <- as.data.frame(player_file[player_file$Team == input$team,] %>%
group_by(Name) %>%
summarise(Tackles_Made = sum(Tackles.Made)))
# Render a barplot
ggplot(data = tackle_made_table, aes(x = reorder(Name, -Tackles_Made), y = Tackles_Made)) +
geom_bar(stat = "identity") +
ggtitle("Tackles Made By Player",
subtitle = paste0("Through ", max(player_file$Round), " Rounds")) +
xlab("Player Name") +
ylab("Tackles Made") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1), panel.grid = element_blank())
})
# Competition Analysis Table
output$toptwenty <- renderPlot({
# Make Tackles Made table
toptwenty <- reactive({player_file[,c('Name', 'Team', input$statistic)]})
# Render a barplot
ggplot(data = toptwenty, aes(x = Name, y = 3, fill = Team)) +
geom_bar(stat = "identity") +
ggtitle("Player",
subtitle = paste0("Through ", max(player_file$Round), " Rounds")) +
xlab("Player Name") +
ylab(paste0(input$statistic)) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1), panel.grid = element_blank())
})
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.