单行使用超过12列

时间:2019-05-01 14:52:13

标签: r shiny

我是一个闪亮的新手,所以我的问题也许很简单,但是在stackoverflow.com上找不到其他人问类似的问题。 我需要构建一个包含12列以上的应用程序。 所以我的问题是,我如何在同一行上有12个以上的textInput元素,并使它们的宽度更紧一点? 这是我的示例代码。

library(shiny) 
u <- fluidPage(   
  titlePanel("Simple Selectable Reactive Function"),   
  sidebarLayout(
    sidebarPanel(),
    mainPanel(
      h2("Results"),
      fluidRow(column(1,
                      textInput("input_ID", label = "text 1",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 2",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 3",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 4",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 5",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 6",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 7",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 8",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 9",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 10",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 11",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text Inp 12",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text Inp 13",
                                value = "123"))

      )
    )
  )
)

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

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您可以在fluidRow中再次使用column。 最后的column又分为两列。

library(shiny) 
u <- fluidPage(   
  titlePanel("Simple Selectable Reactive Function"),   
  sidebarLayout(
    sidebarPanel(),
    mainPanel(
      h2("Results"),
      fluidRow(
              column(1,
                      textInput("input_ID", label = "text 1",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 2",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 3",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 4",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 5",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 6",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 7",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 8",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 9",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 10",
                                value = "123")),
               column(1,
                      textInput("input_ID", label = "text 11",
                                value = "123")),

               column(1, fluidRow(column(6,
                                         textInput("input_ID", label = "text 12",
                                                   value = "123")),
                                  column(6,
                                         textInput("input_ID", label = "text 13",
                                                   value = "123"))))

      )
    )
  )
)

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