闪亮的fluidRow没有效果

时间:2017-08-30 15:43:41

标签: r shiny

知道为什么侧面板中的滑块和下拉选项不在同一行上吗?

require(shiny)

ui <- fluidPage(
  titlePanel("problem"), 
  sidebarLayout(
    sidebarPanel(width = 4,
                 textInput(inputId = 'input', label = 'input'),
                 tabsetPanel(
                   tabPanel("panel 1", 
                            br(),
                            fluidRow(
                              sliderInput('smooth', 'Smooth', 0, 5, 3, step = 1, width='20%'),
                              selectInput("option", "Choose a option", choices = c("option 1", "option 2"), width='40%')
                            )
                            , width='100%'),
                   tabPanel("panel 2", verbatimTextOutput("summary"))
                 )
    ),
    mainPanel(width = 8, p('main panel'))
  )
)

server <- function(input, output){}
shinyApp(ui, server)

enter image description here

2 个答案:

答案 0 :(得分:3)

fluidRow将需要定义column以根据需要显示布局。在你的情况下,以下工作:

fluidRow(
            column(4,
                   sliderInput('smooth', 'Smooth', 0, 5, 3, step = 1)
                   ),
            column(4,
                   selectInput("option", "Choose a option", choices = c("option 1", "option 2"))
                   )
          )

column(4,是每列的宽度。

答案 1 :(得分:1)

这是你想要的吗?

require(shiny)

ui <- fluidPage(
  titlePanel("problem"), 
  sidebarLayout(
    sidebarPanel(width = 4,
                 textInput(inputId = 'input', label = 'input'),
                 tabsetPanel(
                   tabPanel("panel 1", 
                            br(),
                            fluidRow(
                              div(style="display: inline-block;vertical-align:top; width: 49%;",sliderInput('smooth', 'Smooth', 0, 5, 3, step = 1)),
                              div(style="display: inline-block;vertical-align:top; width: 49%;",selectInput("option", "Choose a option", choices = c("option 1", "option 2")))
                            )
                            , width='100%'),
                   tabPanel("panel 2", verbatimTextOutput("summary"))
                 )
    ),
    mainPanel(width = 8, p('main panel'))
  )
)

server <- function(input, output){}
shinyApp(ui, server)

enter image description here