title: R Shiny: how to link checkbox input in ui.R to observe function in server.R?
body: <p>I am trying to create a checkbox input in a Shiny app that allows the data product user to select all options available, select/deselect options one at a time, and throw an error message when all options in the checkbox group are deselected. I am able to get the <code>actionLink</code> input in my ui.R file working, where all options are selected or deselected when the user clicks 'Select All' and the plot updates with the correct values. However, when the user deselects options one at a time, I occasionally get an error and warning message, and the plot does not update. </p>
  
  <p>From what I can tell, every other time the "Social" option is selected/deselected, the console throws an error and warning message and the plot does not update, then if the user selects/deselects the "Social" option again, the plot updates and no error/warning messages are thrown. </p>
  
  <p>I wonder if this has something to do with the way I've set up the <code>observe</code> function in my server.R file, with the data frame manipulations I've done in the reactive expression for 'ssDf', or how I've defined the 'channels_input' reactive expression. </p>
  
  <p>Below is an abstract from my ui.R file.</p>
  
  <pre><code>channel_chr &lt;- list("Display" = "Display", "Paid Search" = "Paid Search", "Organic Search" = "Organic Search", 
                  "Email" = "Email", "Social" = "Social", "Direct" = "Direct", "Referral" = "Referral", 
                  "Affiliate" = "Affiliate")
  
  fluidPage(sidebarLayout(
    sidebarPanel(
  
    ## Other inputs
  
      checkboxGroupInput("channel", label = "Channel(s)", 
                         choices = channel_chr,
                         selected = as.character(channel_chr)),
      actionLink("selectall","Select All"),
  
    ## Other inputs
  
    ),
    mainPanel(
      uiOutput("plot_ui"),
      ggvisOutput("plot")
  
    )
  ))
  </code></pre>
  
  <p>And a relatively small section from my server.R file is below.</p>
  
  <pre><code>channel_chr &lt;- list("Display" = "Display", "Paid Search" = "Paid Search", "Organic Search" = "Organic Search", 
                   "Email" = "Email", "Social" = "Social", "Direct" = "Direct", "Referral" = "Referral", 
                   "Affiliate" = "Affiliate")
  
  shinyServer(function(input, output, session) {
  
      # If "Select All" is chosen in ui.R for input$selectall, select all checkboxes in input$channel
      observe({
              if (input$selectall == 0) { 
                  ## I tried keeping this blank and return(NULL), but saw no difference
              } else if (input$selectall &gt; 0 &amp; input$selectall %% 2 == 0) {
                  updateCheckboxGroupInput(session,"channel","Channel(s)",choices=channel_chr,
                                           selected=as.character(channel_chr))
              } else if (input$selectall %% 2 == 1) {
                  updateCheckboxGroupInput(session,"channel","Channel(s)",choices=channel_chr,
                                       selected=c("Display"))
              } 
      })
  
      channels_input &lt;- reactive ({ 
          temp_chr &lt;- character(length=length(channel_chr))
          temp_channel &lt;- input$channel
          temp_chr[1:length(temp_channel)] &lt;- temp_channel
          return(temp_chr)
      })
  
  # A subset of original data frame as reactive function
  ssDf &lt;- reactive({  
  
      ## contains dplyr, plyr, and ddply manipulations of data frame
      ## according to the user's interactions with ui.R.
  
      ## One example of data frame manipulation in ssDf() reactive function
      ## based on user inputs, and using if/else condition statements
  
      else if (input$[inputB] == [option1] &amp; all(sort(channels_input())!=sort(as.character(channel_chr)))) {
  
              ## If channels_input() != channel_chr { filter only those channels where Channel==channels_input() }
              filteredDat2 &lt;- dplyr::filter(filteredDat, Channel==channels_input()[1])
              for (i in 2:length(channels_input())) {
                  if (channels_input()[i] != "") {
                      filteredDat2 &lt;- rbind(filteredDat2, dplyr::filter(filteredDat, 
                                                                        Channel==channels_input()[i]))
                  }
              }
              filteredDat2 &lt;- ddply(filteredDat2, .(Date, [Column2]), summarize, sum_[Variable1]=sum([Variable1]), 
                                   [Variable2]=weighted.mean([Variable2], [Variable1]), 
                                   [Variable3]=weighted.mean([Variable3], [Variable1]), 
                                   [Variable4]=weighted.mean([Variable4], [Variable1]), 
                                   [Variable5]=weighted.mean([Variable5], [Variable1]))
              ## Subsequent manipulations removed for brevity.        
              return(filteredDat2)
  })
  
  ssDf %&gt;%
      ggvis(~Date, ~[Variable4], stroke = ~TimePeriod) %&gt;%
      layer_lines() %&gt;%
      add_axis("y", title = [Variable4], title_offset = 50) %&gt;%
      scale_datetime("x", domain=c(startNowDate, endNowDate)) %&gt;%
      add_tooltip(all_values, "hover") %&gt;%
      bind_shiny("plot", "plot_ui")
  </code></pre>
  
  <p>Note that I replaced some of my column, variable, and input names with [Column2], [Variable4], etc. for the sake of this post. Also, my tooltip function is not yet functional, so ignore the <code>all_values</code> function within the <code>add_tooltip</code> function in the <code>ggvis</code> pipeline. </p>
  
  <p>Any help with identifying where I went wrong or tips for debugging complex Shiny apps with <code>ggvis</code> would be much appreciated.</p>
  
  <p>Thank you.</p>