I'm new to R and developing a shiny app to analyze baseball data. I want to be able to sort by the players name.
I started by creating a drop down menu to select the desired player name:
ui <- fluidPage(
selectInput(inputId = "num1",
label = "Pitcher Name",
choices = levels(PitcherName),
selected = NULL
),
plotOutput("plot"))
and I want to make the following ggplot show the data depending on which name is selected from the list:
server <- function(input, output) {
output$plot <-renderPlot({
input$num1
bullpen %>%
ggplot(aes(x=PlateLocSide, y=PlateLocHeight)) +
geom_point(data = bullpen, aes(color = TaggedPitchType)) +
scale_color_manual(values = c('green','blue','red','purple','yellow')) +
geom_path(data = sz, aes(x=x, y=z)) +
xlim(-3,3) +
ylim(0,6) +
ggtitle("Pitch Location by Pitch Type")
})
question from:
https://stackoverflow.com/questions/65876916/creating-plots-in-a-shiny-app-with-baseball-data-sorted-by-a-third-variable-pit 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…