title: Shiny conditionalPanel conditions based on NULL values in R?
body: <p>I am writing a Shiny application that will query a database a few times. The queries may take some time, so I am using <code>actionButton</code> to allow the user to control when they are started.</p>
  
  <p>The general flow of the application is:</p>
  
  <ul>
  <li>User loads page, pushes button to load in available choices from the database.</li>
  <li>User selects a row from the available choices, and then kicks off a larger query that will take longer.</li>
  <li>When the query is done, the user will get nice visualizations and other such things.</li>
  </ul>
  
  <p>I know that you can allow the user to select rows from a DataTable using the <code>selection</code> option, and I am currently using the development build so that single-selection can be enabled. My problem is figuring out how to hide certain conditional panels until the user has made a choice. As far as I can tell, the value of the choice is stored in <code>input$[data frame name]_rows_selected</code>. But, until the values are selected, this value is either NULL, or does not exist.</p>
  
  <p>I cannot figure out how to pass to the <code>condition</code> argument of <code>conditionalPanel()</code> a condition which reflects the internal R logic. I've written a minimal working example below which shows the behavior to which I'm referring.</p>
  
  <pre><code>library(shiny)
  library(DT)
  
  # Create sample data
  df_sample_data &lt;- data.frame(name = c("John Smith","Jane Cochran","Belle Ralston","Quincy Darcelio"),
                               color = c("Red","Blue","Red","Green"),
                               age = c(25,52,31,29))
  
  ui &lt;-
      fluidPage(
  
          titlePanel("The Title!"),
  
          sidebarPanel(
  
              h1("Load Data"),
              actionButton("load_data","Load Data"),
              br(),
              conditionalPanel(
  
                  h1("Do Thing"),
                  actionButton("do_thing","Do Thing"),
                  condition = "input.df_data_rows_selected !== undefined")
              ),
  
          mainPanel(
  
              dataTableOutput("df_data"),
              conditionalPanel(
  
                  tableOutput("row_selected"),
                  condition = "input.df_data_rows_selected !== undefined")
              )
      )
  
  server &lt;-
      function(input, output) {
  
          # This function loads the data (in reality it is a server operation)
          uFunc_ReactiveDataLoad &lt;- eventReactive(eventExpr = input$load_data,valueExpr = {
  
              df_data &lt;- df_sample_data
              return(list(display_table = datatable(data = df_data[c("name","age")],
                                                    options = list(dom = "tip"),
                                                    filter = "top",
                                                    selection = "single",
                                                    colnames = c("Person Name" = "name",
                                                                 "Person Age" = "age")),
                          data_table = df_data))
          })
          output$df_data &lt;- renderDataTable(expr = uFunc_ReactiveDataLoad()$display_table)
          output$row_selected &lt;- renderTable(expr = uFunc_ReactiveDataLoad()$data_table[input$df_data_rows_selected,])
      }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>In the current setup, which uses <code>input.df_data_rows_selected !== undefined</code>, the panels are hidden until the data is loaded using the first <code>actionButton</code>. But, I need them to remain hidden unless the user has selected a row. I have tried other things such as:</p>
  
  <ul>
  <li><code>input.df_data_rows_selected !== null</code></li>
  <li><code>input.df_data_rows_selected !== 'null'</code></li>
  <li><code>input.df_data_rows_selected !== ''</code></li>
  <li><code>input.df_data_rows_selected !== 'NULL'</code></li>
  </ul>
  
  <p>...and so on, but I have had no luck. How does the NULL value in R get represented in the JavaScript used for the <code>condition</code> argument to <code>conditionalPanel()</code>?</p>