title: Building in a new toggle button to Shiny app
body: <p>I have a Shiny app that was created awhile ago and I'm trying to add a new feature to it.</p>
  <p>You will notice there are two datasets that one can toggle back and forth with called <code>C4</code> and <code>C3</code>. What I'm trying to do is add a third dataset that one can toggle between called <code>NAM</code>. You might also notice that certain filters are removed when you toggle between <code>C4</code> and <code>C3</code> (as seen in the screenshots). For example: <code>C3</code> has the option of using <code>Partisan Range</code> but that isn't an option for <code>C4</code>. Adding this new dataset (<code>NAM</code>) would be somewhat similar. The goal would be to remove both the Turnout and Partisan &quot;Range&quot; sliders when you select <code>NAM</code> (but every other filter would remain).</p>
  <p>I'm just having some issues embedding the new dataset into the Shiny tool without messing up the previous iteration.</p>
  <p><strong>EDIT based on YBS response: What I’m noticing is that while switching to NAM correctly removes, something still needs to be done on the server side. For example: Let’s say you open the app, select State as PA, set County as “All,” set City as “PITTSBURGH,” move the age slider to between 18 and 35 and don’t touch the turnout and partisan sliders - both remain between 20 and 80. Set to “C4” it correctly shows a size of 0. Switch it to C3 and it correctly shows a size of 0. But when you switch it to “NAM” it also says 0, which is incorrect. It should be 1. What I believe is happening is that when you switch to NAM, it’s just taking how the turnout and partisan sliders are set to under C4 and filtering the data. If you go back and move those two sliders to be between 0 and 100 and then switch back to NAM, it correctly displays 1. How can we fix that so that the results when you switch to NAM are independent from those sliders?</strong></p>
  <p>Here is the <code>server.R</code> file:</p>
  <pre><code>library(dbplyr)
  library(dplyr)
  library(shiny)
  library(shinyWidgets)
  
  server &lt;- function(input, output, session){
    
    mydf &lt;- reactive({get(input$mydata)})
    observeEvent(input$data1, {
      df &lt;- mydf()
      updateSelectizeInput(session, &quot;data2&quot;, &quot;Select County&quot;, server = TRUE, choices = c(&quot;All&quot;, unique(sort(C4$county[C4$state %in% input$data1]))))
    }, priority = 2)
    
    observeEvent(c(input$data1, input$data2), {
      req(mydf())
      df &lt;- mydf()
      if (input$data2 != &quot;All&quot;) {
        updateSelectizeInput(session, &quot;data3&quot;, &quot;Select City&quot;, server = TRUE, choices = c(&quot;All&quot;, unique(sort(C4$city[C4$county %in% input$data2]))))
      } else {
        updateSelectizeInput(session, &quot;data3&quot;, &quot;Select City&quot;, server = TRUE, choices = c(&quot;All&quot;, unique(sort(C4$city[C4$state %in% input$data1]))))
      }
    }, priority = 1)
    
    filtered_data &lt;- reactive({
      req(input$data1,input$data2,input$data3,input$data4,input$data5,input$data6,input$turnout,input$age[1])
      temp_data &lt;- mydf()
      if (sum(&quot;All&quot; %in% input$data1)&lt;1) {
        temp_data &lt;- temp_data[temp_data$state %in% input$data1, ]
      }
      if (input$data2 != &quot;All&quot;) {
        temp_data &lt;- temp_data[temp_data$county == input$data2, ]
      }
      if (sum(&quot;All&quot; %in% input$data3)&lt;1) {
        temp_data &lt;- temp_data[temp_data$city %in% input$data3, ]
      }
      if (input$data4 != &quot;All&quot;) {
        temp_data &lt;- temp_data[temp_data$demo == input$data4, ]
      }
      if (input$data5 != &quot;All&quot;) {
        temp_data &lt;- temp_data[temp_data$registration_status == input$data5, ]
      }
      if (input$data6 != &quot;All&quot;) {
        temp_data &lt;- temp_data[temp_data$vb_voterbase_mailable_flag == input$data6, ]
      }
      
      df2 &lt;- temp_data %&gt;% dplyr::filter(age &gt;= input$age[1] &amp;
                                           age &lt;= input$age[2] &amp;
                                           turnout_score &gt;= input$turnout[1] &amp;
                                           turnout_score &lt;= input$turnout[2])
      if (input$mydata==&quot;C4&quot;) df2 &lt;- df2 %&gt;% dplyr::filter(partisan_score &gt;= input$partisan[1] &amp; partisan_score &lt;= input$partisan[2])
      
      df3 &lt;- if (is.null(input$phones)) df2 else df2 %&gt;%  dplyr::filter(!is.na(phone))
      df3
    })
    
    output$universecount &lt;- renderPrint({
      universecount &lt;- paste(&quot;Universe Size:&quot;, nrow(filtered_data()))
      
      universecount
      
    })
    
  }
  </code></pre>
  <p>And here is the <code>UI.R</code> file <strong>Which includes @YBS edit</strong>:</p>
  <pre><code>    ui &lt;- fluidPage(
    titlePanel(&quot;Builder&quot;),
    sidebarLayout(
      sidebarPanel(
        radioButtons(&quot;mydata&quot;, label = &quot;C4 or C3 or NAM?&quot;, choices = c(&quot;C4&quot;,&quot;C3&quot;, &quot;NAM&quot;), inline=TRUE),
        selectizeInput(&quot;data1&quot;, &quot;Select State&quot;, selected = &quot;MI&quot;, multiple = TRUE, choices = c(unique(sort(C4$state)))),
        selectizeInput(&quot;data2&quot;, &quot;Select County&quot;, choices = NULL),
        selectizeInput(&quot;data3&quot;, &quot;Select City&quot;, selected = &quot;DETROIT&quot;, choices = NULL, multiple = TRUE),
        selectizeInput(&quot;data4&quot;, &quot;Select Demo&quot;, choices = c(&quot;All&quot;, unique(sort(C4$demo)))),
        selectizeInput(&quot;data5&quot;, &quot;Select Registration Status&quot;, choices = c(&quot;All&quot;, unique(sort(C4$registration_status)))),
        selectizeInput(&quot;data6&quot;, &quot;Valid Address&quot;, choices = c(&quot;All&quot;, unique(sort(C4$vb_voterbase_mailable_flag)))),
        sliderInput(&quot;age&quot;, label = h3(&quot;Select Age Range&quot;), 18,
                    35, value = c(18, 20), round = TRUE, step = 1),
        conditionalPanel(condition = &quot;input.mydata=='C4' || input.mydata=='C3'&quot;,
                         sliderInput(&quot;turnout&quot;, label = h3(&quot;Select Turnout Range&quot;), min = 0, max = 100, value = c(20,80))
        ),
        conditionalPanel(condition = &quot;input.mydata=='C4'&quot;,
                         sliderInput(&quot;partisan&quot;, label = h3(&quot;Select Partisan Range&quot;), min = 0, max = 100, value = c(20,80))
        ),
        prettyCheckboxGroup(&quot;phones&quot;, h3(&quot;Only Include Valid Phone Numbers?&quot;), selected = &quot;Yes&quot;, choices = list(&quot;Yes&quot;)),
      ),
      mainPanel(
        verbatimTextOutput(&quot;universecount&quot;),
        tags$head(tags$style(&quot;#universecount{color: red;
                                   font-size: 32px;
                                   font-style: italic;
                                   }&quot;
        )
        )
      )
    ) 
  )
  </code></pre>
  <p>If it helps, here are sample datasets for each:</p>
  <pre><code>    C4 &lt;- structure(list(state = c(&quot;PA&quot;, &quot;MI&quot;, &quot;PA&quot;, &quot;NC&quot;, &quot;WI&quot;, &quot;TX&quot;, 
      &quot;TX&quot;, &quot;NC&quot;, &quot;NC&quot;, &quot;NC&quot;, &quot;PA&quot;, &quot;MI&quot;, &quot;NC&quot;, &quot;AZ&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;PA&quot;, 
      &quot;TX&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;WI&quot;, &quot;TX&quot;, &quot;WI&quot;, &quot;MI&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;MI&quot;, 
      &quot;NC&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;AZ&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;AZ&quot;, &quot;NC&quot;, &quot;AZ&quot;, &quot;WI&quot;, &quot;TX&quot;, 
      &quot;NV&quot;, &quot;NC&quot;, &quot;AZ&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;AZ&quot;, &quot;WI&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;NV&quot;, &quot;MI&quot;
      ), city = c(&quot;PHILADELPHIA&quot;, &quot;SPARTA&quot;, &quot;GLEN CAMPBELL&quot;, &quot;CHARLOTTE&quot;, 
      &quot;MARSHFIELD&quot;, &quot;HUMBLE&quot;, &quot;MANVEL&quot;, &quot;MORRISVILLE&quot;, &quot;CHARLOTTE&quot;, 
      &quot;BURLINGTON&quot;, &quot;PITTSBURGH&quot;, &quot;MONROE&quot;, &quot;MOORESVILLE&quot;, &quot;MARANA&quot;, 
      &quot;LITTLE ELM&quot;, &quot;PHILADELPHIA&quot;, &quot;CHEYNEY&quot;, &quot;AUSTIN&quot;, &quot;AUSTIN&quot;, 
      &quot;DALLAS&quot;, &quot;ALAMO&quot;, &quot;ALGOMA&quot;, &quot;TEMPLE&quot;, &quot;RACINE&quot;, &quot;MIDLAND&quot;, &quot;PLAINVIEW&quot;, 
      &quot;AUSTIN&quot;, &quot;EAU CLAIRE&quot;, &quot;CHARLOTTE&quot;, &quot;SHARPSVILLE&quot;, &quot;HURST&quot;, 
      &quot;GLENDALE&quot;, &quot;MCALLEN&quot;, &quot;ABINGTON&quot;, &quot;KLAGETOH&quot;, &quot;CHARLOTTE&quot;, &quot;TOLLESON&quot;, 
      &quot;KENOSHA&quot;, &quot;EL PASO&quot;, &quot;HENDERSON&quot;, &quot;TAYLORSVILLE&quot;, &quot;MESA&quot;, &quot;FORT WORTH&quot;, 
      &quot;SUGAR LAND&quot;, &quot;GILBERT&quot;, &quot;GENOA&quot;, &quot;HENDERSONVILLE&quot;, &quot;EDNA&quot;, &quot;LAS VEGAS&quot;, 
      &quot;MARLETTE&quot;), county = c(&quot;PHILADELPHIA&quot;, &quot;KENT&quot;, &quot;INDIANA&quot;, &quot;MECKLENBURG&quot;, 
      &quot;MARATHON&quot;, &quot;HARRIS&quot;, &quot;BRAZORIA&quot;, &quot;DURHAM&quot;, &quot;MECKLENBURG&quot;, &quot;ALAMANCE&quot;, 
      &quot;ALLEGHENY&quot;, &quot;MONROE&quot;, &quot;IREDELL&quot;, &quot;PIMA&quot;, &quot;DENTON&quot;, &quot;PHILADELPHIA&quot;, 
      &quot;DELAWARE&quot;, &quot;TRAVIS&quot;, &quot;TRAVIS&quot;, &quot;DALLAS&quot;, &quot;HIDALGO&quot;, &quot;KEWAUNEE&quot;, 
      &quot;BELL&quot;, &quot;RACINE&quot;, &quot;MIDLAND&quot;, &quot;HALE&quot;, &quot;TRAVIS&quot;, &quot;BERRIEN&quot;, &quot;MECKLENBURG&quot;, 
      &quot;MERCER&quot;, &quot;TARRANT&quot;, &quot;MARICOPA&quot;, &quot;HIDALGO&quot;, &quot;MONTGOMERY&quot;, &quot;APACHE&quot;, 
      &quot;MECKLENBURG&quot;, &quot;MARICOPA&quot;, &quot;KENOSHA&quot;, &quot;EL PASO&quot;, &quot;CLARK&quot;, &quot;ALEXANDER&quot;, 
      &quot;MARICOPA&quot;, &quot;TARRANT&quot;, &quot;FORT BEND&quot;, &quot;MARICOPA&quot;, &quot;VERNON&quot;, &quot;HENDERSON&quot;, 
      &quot;JACKSON&quot;, &quot;CLARK&quot;, &quot;SANILAC&quot;), age = c(35L, 33L, 24L, 33L, 31L, 
      24L, 33L, 26L, 21L, 28L, 31L, 30L, 35L, 31L, 30L, 34L, 29L, 35L, 
      28L, 35L, 31L, 33L, 24L, 33L, 20L, 21L, 29L, 23L, 32L, 31L, 21L, 
      35L, 24L, 24L, 33L, 34L, 23L, 28L, 29L, 22L, 22L, 29L, 29L, 33L, 
      30L, 28L, 26L, 22L, 34L, 26L), demo = c(&quot;Caucasian&quot;, &quot;Caucasian&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Uncoded&quot;, 
      &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Uncoded&quot;, &quot;Caucasian&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, &quot;Hispanic&quot;, 
      &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, 
      &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Hispanic&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
      &quot;Hispanic&quot;, &quot;Asian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, 
      &quot;Caucasian&quot;, &quot;Caucasian&quot;), turnout_score = c(53.2, 21.2, 8.7, 
      57.6, 52.9, 8.7, 10.5, 13.9, 3.7, 26, 6.1, 9.2, 8.2, 7.6, 12.2, 
      8.4, 2.5, 8, 8.2, 5.4, 24, 4.8, 3.3, 57.4, 44.2, 4.8, 5.2, 37.5, 
      48.1, 35.1, 16.3, 18.8, 2, 22.2, 67.5, 71.6, 14.3, 85.2, 1.7, 
      51.1, 14.5, 32.2, 13.3, 18.1, 52, 26.7, 41.3, 8.6, 52.4, 3.3), 
          partisan_score = c(95.8, 25.5, 44.8, 98, 31.7, 96.7, 82.8, 
          82.5, 91.1, 1, 94.8, 12.1, 25.6, 6.3, 35.4, 99, 98.6, 67.4, 
          13, 55.7, 44.2, 34.9, 53.8, 68.5, 24, 76.7, 94, 41.4, 96.7, 
          93.6, 69.6, 89.9, 43.2, 3.8, 99.1, 98.2, 98, 92.2, 42.6, 
          97, 92.1, 73.4, 68.7, 83.7, 10.6, 29.7, 98.7, 49.4, 97.9, 
          30.3), phone = c(NA, 1L, 1L, 1L, 1L, 1L, 1L, 1L, NA, 1L, 
          1L, 1L, 1L, NA, 1L, NA, NA, 1L, NA, 1L, 1L, 1L, NA, 1L, NA, 
          NA, 1L, NA, 1L, NA, 1L, 1L, 1L, 1L, NA, 1L, NA, 1L, NA, 1L, 
          NA, 1L, 1L, NA, 1L, 1L, 1L, 1L, 1L, 1L), registration_status = c(&quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Unregistered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;, &quot;Registered&quot;, &quot;Unregistered&quot;, &quot;Registered&quot;, 
          &quot;Registered&quot;), vb_voterbase_mailable_flag = c(&quot;Yes&quot;, &quot;Yes&quot;, 
          &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;No&quot;, 
          &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;&quot;, &quot;Yes&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
          &quot;Yes&quot;, &quot;No&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
          &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
          &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
          &quot;&quot;, &quot;Yes&quot;, &quot;Yes&quot;)), class = &quot;data.frame&quot;, row.names = c(NA, 
      -50L))
  
  C3 &lt;- structure(list(state = c(&quot;PA&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;NC&quot;, &quot;TX&quot;, 
  &quot;PA&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;NV&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;MI&quot;, &quot;PA&quot;, &quot;NC&quot;, &quot;AZ&quot;, &quot;TX&quot;, 
  &quot;TX&quot;, &quot;MI&quot;, &quot;WI&quot;, &quot;TX&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;MI&quot;, &quot;PA&quot;, &quot;NC&quot;, 
  &quot;NV&quot;, &quot;NV&quot;, &quot;AZ&quot;, &quot;PA&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;MI&quot;, &quot;TX&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;TX&quot;, 
  &quot;TX&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;MI&quot;, &quot;TX&quot;, &quot;MI&quot;, &quot;MI&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;MI&quot;
  ), city = c(&quot;PHILADELPHIA&quot;, &quot;WARFORDSBURG&quot;, &quot;PITTSBURGH&quot;, &quot;SLATON&quot;, 
  &quot;WAYNESVILLE&quot;, &quot;KATY&quot;, &quot;PUNXSUTAWNEY&quot;, &quot;BROOKHAVEN&quot;, &quot;LAREDO&quot;, 
  &quot;LAS VEGAS&quot;, &quot;SEALY&quot;, &quot;ROSTRAVER TOWNSHIP&quot;, &quot;DETROIT&quot;, &quot;SWISSVALE&quot;, 
  &quot;RALEIGH&quot;, &quot;YUMA&quot;, &quot;PFLUGERVILLE&quot;, &quot;LAGUNA VISTA&quot;, &quot;WHITEHALL&quot;, 
  &quot;FRANKSVILLE&quot;, &quot;CEDAR PARK&quot;, &quot;WINSTON SALEM&quot;, &quot;ABILENE&quot;, &quot;WILKES BARRE&quot;, 
  &quot;WACO&quot;, &quot;WARREN&quot;, &quot;LEETSDALE&quot;, &quot;WILLOW SPRING&quot;, &quot;HENDERSON&quot;, 
  &quot;CARSON CITY&quot;, &quot;MESA&quot;, &quot;HARRISBURG&quot;, &quot;WILLOW SPRING&quot;, &quot;AUSTIN&quot;, 
  &quot;BIRMINGHAM&quot;, &quot;HOUSTON&quot;, &quot;JACKSONVILLE&quot;, &quot;ROCKWALL&quot;, &quot;AMARILLO&quot;, 
  &quot;CONROE&quot;, &quot;WARMINSTER&quot;, &quot;RED LION&quot;, &quot;BELDING&quot;, &quot;CEDAR HILL&quot;, 
  &quot;NEW ERA&quot;, &quot;CHARLEVOIX&quot;, &quot;HORIZON CITY&quot;, &quot;BRYAN&quot;, &quot;DALLAS&quot;, &quot;GRAND RAPIDS&quot;
  ), county = c(&quot;PHILADELPHIA&quot;, &quot;FULTON&quot;, &quot;ALLEGHENY&quot;, &quot;LUBBOCK&quot;, 
  &quot;HAYWOOD&quot;, &quot;FORT BEND&quot;, &quot;JEFFERSON&quot;, &quot;DELAWARE&quot;, &quot;WEBB&quot;, &quot;CLARK&quot;, 
  &quot;AUSTIN&quot;, &quot;WESTMORELAND&quot;, &quot;WAYNE&quot;, &quot;ALLEGHENY&quot;, &quot;WAKE&quot;, &quot;YUMA&quot;, 
  &quot;TRAVIS&quot;, &quot;CAMERON&quot;, &quot;MUSKEGON&quot;, &quot;RACINE&quot;, &quot;WILLIAMSON&quot;, &quot;FORSYTH&quot;, 
  &quot;TAYLOR&quot;, &quot;LUZERNE&quot;, &quot;MCLENNAN&quot;, &quot;MACOMB&quot;, &quot;ALLEGHENY&quot;, &quot;WAKE&quot;, 
  &quot;CLARK&quot;, &quot;CARSON CITY&quot;, &quot;MARICOPA&quot;, &quot;DAUPHIN&quot;, &quot;WAKE&quot;, &quot;TRAVIS&quot;, 
  &quot;OAKLAND&quot;, &quot;HARRIS&quot;, &quot;ONSLOW&quot;, &quot;ROCKWALL&quot;, &quot;POTTER&quot;, &quot;MONTGOMERY&quot;, 
  &quot;BUCKS&quot;, &quot;YORK&quot;, &quot;IONIA&quot;, &quot;DALLAS&quot;, &quot;OCEANA&quot;, &quot;CHARLEVOIX&quot;, &quot;EL PASO&quot;, 
  &quot;BRAZOS&quot;, &quot;DALLAS&quot;, &quot;KENT&quot;), age = c(32L, 29L, 25L, 26L, 32L, 
  24L, 25L, 35L, 30L, 30L, 35L, 27L, 30L, 25L, 29L, 21L, 35L, 31L, 
  25L, 35L, 20L, 24L, 21L, 27L, 27L, 33L, 19L, 22L, 22L, 33L, 21L, 
  27L, 21L, 31L, 35L, 31L, 31L, 32L, 24L, 30L, 29L, 30L, 31L, 34L, 
  30L, 24L, 30L, 35L, 20L, 25L), demo = c(&quot;African-American&quot;, &quot;Caucasian&quot;, 
  &quot;African-American&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, 
  &quot;African-American&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, 
  &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Hispanic&quot;, 
  &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;), turnout_score = c(7.6, 
  30.9, 6.6, 2.6, 59.4, 1.9, 17.6, 2.4, 51.7, 25.4, 1.5, 2.9, 13.1, 
  6.9, 26.9, 35.5, 19.2, 30.8, 18.9, 55.2, 11.6, 17.9, 6.8, 1.4, 
  6.9, 29.1, 25.7, 4, 44.7, 30.9, 67.5, 26.6, 25.6, 1.3, 58.8, 
  1.4, 18.6, 19.2, 4.1, 7.6, 8.2, 16.7, 18.6, 7.4, 3.1, 41.7, 2.4, 
  18.1, 8.5, 74.8), partisan_score = c(98.4, 1.2, 98.5, 60, 0.5, 
  73.3, 0.7, 6.8, 93.3, 0.7, 33.3, 72.2, 96.3, 98.1, 92.1, 98.1, 
  64.1, 78.7, 40.5, 6.3, 61.1, 98.1, 77.4, 95.9, 57.6, 36, 3.3, 
  98.8, 32.5, 1.5, 72.6, 1, 5.3, 76.2, 42.6, 82.9, 67.2, 36.3, 
  77.3, 18, 97.2, 27.5, 33, 72.4, 47.8, 65.3, 44.9, 86.4, 69.6, 
  98.2), phone = c(NA, 1L, NA, NA, 1L, NA, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, NA, NA, 1L, NA, NA, NA, 1L, 1L, 1L, NA, 1L, NA, 1L, NA, 
  NA, 1L, 1L, 1L, 1L, 1L, 1L, NA, 1L, NA, NA, 1L, NA, NA, NA, 1L, 
  1L, NA, NA, 1L, NA, NA, NA), registration_status = c(&quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;), vb_voterbase_mailable_flag = c(&quot;No&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -50L))
  
  NAM &lt;- structure(list(state = c(&quot;TX&quot;, &quot;WI&quot;, &quot;NV&quot;, &quot;MI&quot;, &quot;PA&quot;, &quot;MI&quot;, 
  &quot;MI&quot;, &quot;NC&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;NC&quot;, &quot;PA&quot;, &quot;NV&quot;, &quot;TX&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;MI&quot;, 
  &quot;WI&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;NV&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;NV&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;PA&quot;, 
  &quot;TX&quot;, &quot;TX&quot;, &quot;MI&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;MI&quot;, &quot;NC&quot;, &quot;PA&quot;, &quot;PA&quot;, 
  &quot;PA&quot;, &quot;TX&quot;, &quot;NC&quot;, &quot;AZ&quot;, &quot;NC&quot;, &quot;TX&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;TX&quot;, &quot;PA&quot;, &quot;NC&quot;
  ), city = c(&quot;SAN JUAN&quot;, &quot;BROOKFIELD&quot;, &quot;RENO&quot;, &quot;CENTRAL LAKE&quot;, 
  &quot;PITTSBURGH&quot;, &quot;SOUTHFIELD&quot;, &quot;CLIO&quot;, &quot;GREENSBORO&quot;, &quot;BLAKESLEE&quot;, 
  &quot;CRESSONA&quot;, &quot;FAYETTEVILLE&quot;, &quot;DOYLESTOWN&quot;, &quot;SPARKS&quot;, &quot;RICHARDSON&quot;, 
  &quot;GARNER&quot;, &quot;COPPERAS COVE&quot;, &quot;TAYLOR&quot;, &quot;HILBERT&quot;, &quot;ODESSA&quot;, &quot;HATBORO&quot;, 
  &quot;MC KEES ROCKS&quot;, &quot;LAS VEGAS&quot;, &quot;PHILADELPHIA&quot;, &quot;LAREDO&quot;, &quot;HENDERSON&quot;, 
  &quot;AZLE&quot;, &quot;LEAGUE CITY&quot;, &quot;COLLEGEVILLE&quot;, &quot;GARLAND&quot;, &quot;HOUSTON&quot;, 
  &quot;DEARBORN HEIGHTS&quot;, &quot;PITTSBURGH&quot;, &quot;PHILADELPHIA&quot;, &quot;LANCASTER&quot;, 
  &quot;AZLE&quot;, &quot;TRENTON&quot;, &quot;MIDDLESEX&quot;, &quot;PHILADELPHIA&quot;, &quot;ACME&quot;, &quot;ALTOONA&quot;, 
  &quot;LUFKIN&quot;, &quot;ASHEVILLE&quot;, &quot;TEMPE&quot;, &quot;CHAPEL HILL&quot;, &quot;BANDERA&quot;, &quot;HUTTO&quot;, 
  &quot;DOWNINGTOWN&quot;, &quot;ARLINGTON&quot;, &quot;DILLSBURG&quot;, &quot;GASTONIA&quot;), county = c(&quot;HIDALGO&quot;, 
  &quot;WAUKESHA&quot;, &quot;WASHOE&quot;, &quot;ANTRIM&quot;, &quot;ALLEGHENY&quot;, &quot;OAKLAND&quot;, &quot;GENESEE&quot;, 
  &quot;GUILFORD&quot;, &quot;MONROE&quot;, &quot;SCHUYLKILL&quot;, &quot;CUMBERLAND&quot;, &quot;BUCKS&quot;, &quot;WASHOE&quot;, 
  &quot;DALLAS&quot;, &quot;JOHNSTON&quot;, &quot;CORYELL&quot;, &quot;WAYNE&quot;, &quot;CALUMET&quot;, &quot;ECTOR&quot;, 
  &quot;MONTGOMERY&quot;, &quot;ALLEGHENY&quot;, &quot;CLARK&quot;, &quot;PHILADELPHIA&quot;, &quot;WEBB&quot;, &quot;CLARK&quot;, 
  &quot;PARKER&quot;, &quot;GALVESTON&quot;, &quot;MONTGOMERY&quot;, &quot;DALLAS&quot;, &quot;HARRIS&quot;, &quot;WAYNE&quot;, 
  &quot;ALLEGHENY&quot;, &quot;PHILADELPHIA&quot;, &quot;LANCASTER&quot;, &quot;PARKER&quot;, &quot;WAYNE&quot;, 
  &quot;JOHNSTON&quot;, &quot;PHILADELPHIA&quot;, &quot;WESTMORELAND&quot;, &quot;BLAIR&quot;, &quot;ANGELINA&quot;, 
  &quot;BUNCOMBE&quot;, &quot;MARICOPA&quot;, &quot;ORANGE&quot;, &quot;BANDERA&quot;, &quot;WILLIAMSON&quot;, &quot;CHESTER&quot;, 
  &quot;TARRANT&quot;, &quot;YORK&quot;, &quot;GASTON&quot;), age = c(25L, 35L, 33L, 28L, 30L, 
  28L, 28L, 32L, 32L, 35L, 28L, 23L, 29L, 29L, 34L, 33L, 23L, 30L, 
  35L, 22L, 32L, 25L, 33L, 19L, 24L, 21L, 31L, 21L, 35L, 20L, 26L, 
  28L, 26L, 24L, 23L, 23L, 22L, 28L, 23L, 21L, 32L, 30L, 27L, 24L, 
  27L, 19L, 31L, 31L, 19L, 35L), demo = c(&quot;Hispanic&quot;, &quot;Caucasian&quot;, 
  &quot;African-American&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Other&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Uncoded&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;African-American&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Asian&quot;, &quot;Hispanic&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;African-American&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;, 
  &quot;Uncoded&quot;, &quot;Caucasian&quot;, &quot;Caucasian&quot;), turnout_score = c(11.5, 
  92.2, 25.5, 80.2, 19.8, 80.8, 9.5, 38.6, 21.7, 64.9, 6.3, 24.1, 
  41.7, 79.8, 43.9, 28.2, 11.8, 84.1, 12.6, 70.4, 48.4, 7.6, 80.2, 
  15, 60.9, 44.8, 8.5, 51.7, 44.9, 42.4, 83.7, 84, 72.5, 76.3, 
  9.9, 82.2, 41.9, 9.1, 14.8, 51.8, 82.5, 34.7, 93.7, 46.1, 16.8, 
  32.7, 4.2, 83.3, 27.5, 7.6), partisan_score = c(55.6, 58.9, 5.5, 
  97, 1.2, 98.6, 71.7, 94.3, 96.4, 94.8, 93.7, 16.8, 24.3, 98.8, 
  4.1, 29.6, 30.4, 20.9, 36, 98.6, 83.4, 23.1, 99.1, 63.4, 62.2, 
  34.1, 79, 98.5, 75.6, 75.8, 92.8, 98.9, 98.7, 0.9, 77.7, 97.5, 
  97, 88.1, 96.3, 2, 1, 90.3, 97.3, 78.9, 11.7, 64.9, 95.8, 99.8, 
  7.6, 2.7), phone = c(1L, NA, NA, NA, 1L, 1L, 1L, NA, NA, 1L, 
  1L, NA, 1L, NA, 1L, NA, NA, NA, 1L, NA, NA, NA, 1L, 1L, NA, 1L, 
  NA, NA, 1L, 1L, NA, NA, NA, NA, NA, NA, 1L, NA, NA, 1L, NA, 1L, 
  NA, NA, NA, NA, NA, NA, NA, 1L), registration_status = c(&quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, 
  &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;, &quot;Registered&quot;), vb_voterbase_mailable_flag = c(&quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;No&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, 
  &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;, &quot;Yes&quot;)), class = &quot;data.frame&quot;, row.names = c(NA, 
  -50L))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/91P4j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/91P4j.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/ogr1E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ogr1E.png" alt="enter image description here" /></a></p>