I am trying to build an app using the wonderful Shiny library in R, and I would like it to produce some error and status messages for the user. To get this to work I am using conditionalPanel in conjunction with some Boolean flags on the output object to render panels for the error and status messages. According to the documentation, this strategy should be working for me, but it is not.
I have boiled the idea down to a simple ui and server script, essentially what I am trying to do is this:
ui.R
library("shiny")
shinyUI(pageWithSidebar(
headerPanel('Hey There Guys!'),
sidebarPanel(
h4('Switch the message on and off!'),
actionButton('switch', 'Switch')
),
mainPanel(
conditionalPanel(condition = 'output.DISP_MESSAGE',
verbatimTextOutput('msg')
)
)
))
server.R
library('shiny')
shinyServer(function(input, output) {
output$DISP_MESSAGE <- reactive({input$switch %% 2 == 0})
output$msg <- renderPrint({print("Hey Ho! Let's Go!")})
})
The idea here is that pressing the button should toggle the message Hey ho! Let's go! on and off. With the code as posted, this does not work. The message does not display when loading the page in Chrome, and pressing the button does nothing. I have the most up to date version of Shiny from CRAN. Any help would be greatly appreciated!