2013-06-24 86 views
11

我想知道是否可以在UI上并排显示复选框选项。我已经尝试了一些示例代码:R Shiny:并排复选框

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; 

)) 

回答

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

我是新来引导,但如果它是一个单选按钮闪亮?你如何应用上述框架?单选按钮是相当棘手的,因为它是与单独的功能相反的单一功能。谢谢, – user1234440

+0

https://github.com/plataformatec/simple_form/issues/649暗示也许你在描述什么。您可以使用基本标签构建模块构建自己的控件。 – user1609452

+0

除非你非常懒惰像我这样的情况下你可以'gsub' – user1609452

13

更换可以使用checkboxGroupInputinline = TRUE PARAM:

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