Hello,
I am currently working on a shiny dashboard that runs perfectly locally but returns the following error when I attempt to publish it:
Error in value[[3L]](cond) : object of type 'closure' is not subsettable
I've poked around and understand that the error stems from trying to treat a function like a data frame, but I don't think I do so anywhere in the code. As an example, my UI looks generally like:
ui <- dashboardPage(
dashboardHeader(title = "Dashboard", titleWidth = 350),
dashboardSidebar(
sidebarMenu(
menuItem("Pitchers", tabName = "Pitchers", icon = icon("baseball-ball")),
menuItem("Hitters", tabName = "Hitters", icon = icon("male"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "Pitchers",
selectInput("dataset", label = "Pitcher", choices = df$Pitcher, selected = df$Pitcher["Lamon, Owen"])
fluidRow(
box(title = "Velocity by Pitch Number", plotOutput("VeloPlot"), collapsible = TRUE, solidHeader = TRUE, status = "primary", width = 12)),
and in my Server code I read a csv, store it as a data frame, and refer to the inputs using "render". I commented the read.csv line per some suggestions I found online:
server <- function(input, output, session){
#/df <- read.csv("R/Master.csv", stringsAsFactors=FALSE, sep=",", header=TRUE)
df <- transform(df, Velocity = cut(RelSpeed, 5))
df <- df %>% mutate(
Chase = if_else(((PlateLocSide < -.95 | PlateLocSide > .95 | PlateLocHeight < 1.6 | PlateLocHeight > 3.5) & (PitchCall == "StrikeSwinging" | PitchCall == "FoulBall" | PitchCall == "InPlay")), 'Yes', 'No' ),
HitHard = if_else(ExitSpeed > 90, 'Yes', 'No'),
InZone = if_else(PlateLocSide < .95 & PlateLocSide > -.95 & PlateLocHeight > 1.6 & PlateLocHeight < 3.5, 'Yes', 'No'))
df <- df %>%
mutate(
TiltHMS = hms(Tilt),
TiltHours = (hour(TiltHMS) + minute(TiltHMS)/60)
)
output$VeloPlot <- renderPlot({
df %>% filter(Pitcher == input$dataset) %>% ggplot() + geom_line(aes(x = PitchNo, y = RelSpeed, color = TaggedPitchType)) + xlab("Pitch Number") + ylab("Velocity") + ggtitle("Velocities by Pitch Number")
})
Any guidance would be greatly appreciated!