R Shiny:并排复选框

时间:2013-06-24 13:52:19

标签: r shiny

我想知道是否可以在UI上并排显示复选框选项。我试过的一些示例代码:

shinyUI(pageWithSidebar(
  headerPanel("Example"),
  sidebarPanel(   
    checkboxInput(inputId = "simOption", label = "Historical Data",value=TRUE),
    checkboxInput(inputId = "simOption2", label = "Historical Data 2",value=TRUE)


  ),

  mainPanel(
tabsetPanel(

  tabPanel("Heatmap",
           plotOutput("temp")
  ),
  tabPanel("About"),

  id="tabs"
)#tabsetPanel  

  )#mainPane;

))

2 个答案:

答案 0 :(得分:13)

尝试捏造一些引导语法:

shinyUI(pageWithSidebar(
  headerPanel("Example"),
  sidebarPanel(   

    withTags(div(class='row-fluid',
                 div(class='span3', checkboxInput(inputId = "simOption", label = "Historical Data",value=TRUE)),
                 div(class='span5', checkboxInput(inputId = "simOption2", label = "Historical Data 2",value=TRUE))
    ))



  ),

  mainPanel(
tabsetPanel(

  tabPanel("Heatmap",
           plotOutput("temp")
  ),
  tabPanel("About"),

  id="tabs"
)#tabsetPanel  

  )#mainPane;

))

https://medium.com/what-i-learned-building/99fdd6e46586

编辑水平单选按钮

来自?radiobutton

radioButtons("dist", "Distribution type:",
             c("Normal" = "norm",
               "Uniform" = "unif",
               "Log-normal" = "lnorm",
               "Exponential" = "exp"))

替换为

 gsub("label class=\"radio\"", "label class=\"radio inline\"",radioButtons("dist", "Distribution type:",
             c("Normal" = "norm",
               "Uniform" = "unif",
               "Log-normal" = "lnorm",
               "Exponential" = "exp")))
  )

答案 1 :(得分:13)

您可以将checkboxGroupInputinline = TRUE param:

一起使用
checkboxGroupInput(inputId = "simOption", label = "",
                   choices = c("Historical Data" = TRUE,
                               "Historical Data 2" = TRUE),
                   inline = TRUE)