Single tick resolution only in checkboxGroupInput

In this brilliant application, I need to allow the user to check only one checkbox. Anyway to achieve this?

ui.R

library(shiny) shinyUI(fluidPage( titlePanel("abc"), sidebarLayout( sidebarPanel( checkboxGroupInput("choice", "What will you like to see?", choices=c("red","green")), conditionalPanel( condition = "input.choice == 'red'", sliderInput("slider1","slide",min=0,max=100,value=100,step=1,animate=TRUE)), conditionalPanel( condition="input.choice=='green'", selectInput("choice","Select", c("a","b","c")), sliderInput("slider2","slide",min=0,max=100,value=100,step=1,animate=TRUE)) ), mainPanel( "abc" ) ) )) 

server.R

 shinyServer(function(input, output) { } ) 
+6
source share
2 answers

Instead, you should use radioButtons() , for example:

 radioButtons(inputId="choice", label="What would you like to see?", choices=c("red","green")) 

This will allow the user to select only one of the options.

Note I fixed the quotation marks in the choices part of this answer. Thanks @Limbu for pointing out a typo.

+11
source

You forgot to put quotation marks around each choice, you grouped two options as one choice

 radioButtons(inputId="choice", label="What would you like to see?", choices=c("red","green")) 
+2
source

Source: https://habr.com/ru/post/980046/


All Articles