Minimum checkbox selection

Is there anyway I can let a group of checkboxes have at least one choice?

I would like the vector to have at least one selection instead of zero. Is it possible to change the input element if this checkbox group doesn't support UI.R

library(shiny)

# Define UI for miles per gallon application
shinyUI(pageWithSidebar(

  # Application title
  titlePanel("Demo Assignment for SHINY Coursera"),

  # Sidebar with checkbox to select the variable to plot against mpg
  # and to specify whether outliers should be included
  sidebarPanel(



    selectInput("variable1", "Performance Variable:",
                list("MPG" = "mpg", 
                     "qsec" = "qsec")),

    checkboxGroupInput("variable", "Variable:",
                       c("Cylinders" = "cyl", 
                         "Displacement" = "disp", 
                         "HP" = "hp", 
                         "Rear Axle Ratio" = "drat", 
                         "Weight" = "wt", 
                         "Transmission" = "am", 
                         "Carburetors" = "carb", 
                         "Gears" = "gear"), selected = "cyl")


  ),

  # Show the caption and plot of the requested variable against mpg
  mainPanel(

    h4(textOutput("Var_1")),
    h4(textOutput("Var_2")),
    h4(textOutput("caption")),

    h4("Analysis:"),

    plotOutput("mpgPlot")
  )
))

      

+3


source to share





All Articles