Подтвердить что ты не робот

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;

))
4b9b3361

Ответ 1

Попробуйте fudging некоторый синтаксис бутстрапа:

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

EDIT для горизонтальной кнопки

из ?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")))
  )

Ответ 2

Вы можете использовать checkboxGroupInput с параметром inline = TRUE:

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