Building a Post-Game Pitcher Report with Statcast Data

User Interface (UI) Code

CSS Styling

wellPanel(style = "background: white; border-color: black; border-width: 2px", …)hr(style="border-color: black;")

Updating Select Inputs

choices = ""

Text Outputs

h2(strong(textOutput("selected_pitcher")))h2(textOutput("selected_game"))

Server Code

Factor

NL_CY$pitch_type <- factor(NL_CY$pitch_type, levels = c("FF", "SI", "FC", "CS", "CU", "KC", "SL", "CH", "FS"))NL_CY$pitch_name <- factor(NL_CY$pitch_name, levels = c("4-Seam Fastball", "Sinker", "Cutter", "Curveball", "Knuckle Curve", "Slider", "Changeup", "Split-Finger"))

Observe Event

observeEvent(input$PitcherInput, 
updateSelectInput(session,
inputId = "GameInput",
label = "Select Game",
choices = sort(unique(NL_CY$game_date[NL_CY$player_name == input$PitcherInput]))))
server <- function(input, output, session) { … }

Render Text

output$selected_pitcher <- renderText({paste(input$PitcherInput)})

output$selected_game <- renderText({paste(input$GameInput)})

DT (Data Tables)

output$pitcher_summary_table <- renderDataTable({
table <- NL_CY %>%
...
tableFilter <- reactive({table})
datatable(tableFilter(),
options = list(dom = 't',
columnDefs = list(list(targets = 0, visible = FALSE)))) %>%
formatStyle(c(1,2), `border-left` = "solid 1px") %>%
formatStyle(c(2,5,7), `border-right` = "solid 1px")
})

Wrapping It Up

--

--

--

Driveline Baseball Operations Analyst

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introducing sia_exporter, a lightweight and flexible exporter to send Sia metrics to Prometheus

Code Review: Etiquette Guidlines

Data Visualization — Bivariate Analysis in R

Setup Elasticsearch & Kibana via Docker

Bot Framework Composer — Property management | Part 2

Now where the hell is this piece of code?

Virtualenv migration notes

Bug Life Cycle

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sam Bornstein

Sam Bornstein

Driveline Baseball Operations Analyst

More from Medium

Cozy Collecting, Case Study: Getting a Decade’s Worth of Weather Data in R

R-Programming -a little insight!

Do large companies retain their employees better?