【问题标题】:R Shiny: Side by Side CheckboxR Shiny:并排复选框
【发布时间】:2013-06-21 01:29:39
【问题描述】:

我想知道是否可以在 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;

))

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    尝试捏造一些引导语法:

    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")))
      )
    

    【讨论】:

    • 我是 bootstrap 新手,但如果它是闪亮的单选按钮呢?如何应用上述框架?单选按钮相当棘手,因为它是一个单一的功能,而不是两个独立的功能。谢谢,
    • github.com/plataformatec/simple_form/issues/649 暗示了您所描述的内容。您可以使用基本的标签构建块构建自己的控件。
    • 除非你和我一样很懒,否则你可以gsub
    【解决方案2】:

    您可以将checkboxGroupInputinline = TRUE 参数一起使用:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多