title: How To make hideGroup into showGroup with Shiny and Leaflet
body: <p>I have a fairly complex Shiny app with a leaflet map on it and many other controls. I have made a very simplified version of it below. </p>
  
  <p>I have set the two groups (an addMarker and an addCircles group) initially to not plot by placing both layers in a hideGroup function. I then run the app and manually switch them on in the addLayersControl in the checkbox on the map. The radius of the addCircles group is controlled reactively by a sliderInput, however, this then runs the hideGroup functions again and they are not plotted, which I now do not want to happen. I want them to remain plotted.</p>
  
  <p>How do I start off with hidden groups, show them by switching them on via the map layer control and then send a new value to the addCirlces radius without the groups then switching back to the hidegroup default please?</p>
  
  <p>Do I tackle the problem with isolate, I haven’t had any success that way yet? Or is there an if_else conditional approach I should take to invoke a showGroup state instead? Thanks in advance.</p>
  
  <pre><code>library(shiny)
  library(tidyverse)
  library(leaflet)
  library(sf)
  
  ui &lt;- fluidPage(
    column(width = 4,
           sliderInput("slt_kam_reach",
                       "KAM",
                       min = 0,
                       max = 50000,
                       step = 1000,
                       value = 5000
           )
           ),
    column(width = 8,
       leafletOutput("lflt_map")
       )
  )
  
  kam_data &lt;- data.frame(
    kam_code = c("abc123", "def456"),
    lng = c(18.5, 18.7),
    lat = c(-33.5, -33.7)
  )
  
  kam_data_sf &lt;- st_as_sf(
      kam_data,
      coords = c("lng", "lat"),
      crs = "+proj=longlat +datum=WGS84"
    )
  
  server &lt;- function(input, output, session){
  
    output$lflt_map &lt;- renderLeaflet({
  
      leaflet() %&gt;% 
        addTiles(group = "OSM") %&gt;% 
        addLayersControl(
          overlayGroups = c("KAM",
                            "KAM_reach"),
          options = layersControlOptions(
            collapsed = F
          )
        ) %&gt;% 
        addMarkers(data = kam_data_sf,
                   group = "KAM") %&gt;% 
        addCircles(data = kam_data_sf,
                   group = "KAM_reach",
                   radius = input$slt_kam_reach
                   ) %&gt;% 
        hideGroup("KAM") %&gt;% 
        hideGroup("KAM_reach")
  
    })
  }
  shinyApp(ui, server)
  </code></pre>