在这个闪亮的应用程序中,我需要允许用户只勾选一个复选框。究竟是否有这个目标呢?
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) {
}
)发布于 2014-12-22 18:15:55
您可能应该使用radioButtons()代替,就像这样;
radioButtons(inputId="choice", label="What would you like to see?",
choices=c("red","green"))这将使用户只选择其中一个选项。
Note I修正了这个答案的choices部分中的引号。感谢林布指出了错误。
发布于 2015-06-16 18:23:41
您忘了在每个选项周围加上引号,您将这两个选项分组为一个选项。
radioButtons(inputId="choice", label="What would you like to see?",
choices=c("red","green"))https://stackoverflow.com/questions/27607566
复制相似问题