I have a Shiny app that doesn't give any error but clearly my conditionalPanel are not working properly. When I select the inputs some graphs get updated and some don't. For example if I select week and change the condition for 0 or 1 the graphs get updated, but if I select rel the graph gets update for 1 but not for 4 (If I do this outside the Shiny app it works for all cases). This is how the code looks like: UI.R
shinyUI(pageWithSidebar(
headerPanel(' '),
sidebarPanel(
selectInput('zcol', 'Variable to be fixed', names(taxi[,-c(1,4,5,7,8,9,10,11)])),
conditionalPanel(condition = "input.zcol == 'week'",
selectInput("levels", "Levels",c(0,1)
)),
conditionalPanel(condition = "input.zcol == 'tollfree'",
selectInput("levels", "Levels",c(0,1)
)),
conditionalPanel(condition = "input.zcol == 'rel'",
selectInput("levels", "Levels",c(1,4)
)),
conditionalPanel(condition = "input.zcol == 'source'",
selectInput("levels", "Levels",c(1,2)
)),
conditionalPanel(condition = "input.zcol == 'hour'",
selectInput("levels", "Levels",c(seq(0,23))
))
),
mainPanel(
plotOutput('plot1'),
plotOutput('plot2')
)
))
Server.R
shinyServer(function(input, output, session) {
simiData <- reactive({
eval(substitute(taxi %>% group_by(simi.mean,col) %>% summarise(mean = mean(prop.conv)) %>%
filter(col==input$levels) %>% select(simi.mean,mean),
list(col=as.symbol(input$zcol))))
})
distData <- reactive({
eval(substitute(taxi %>% group_by(dist.mean,col) %>% summarise(mean = mean(prop.conv)) %>%
filter(col==input$levels) %>% select(dist.mean,mean),
list(col=as.symbol(input$zcol))))
})
output$plot1 <- renderPlot({
plot(simiData(),xlim=c(0,max(simiData()$simi.mean)),ylim=c(0,max(simiData()$mean)))
})
output$plot2 <- renderPlot({
plot(distData())
})
})
Any suggestions? Thanks!