以表格格式嵌入单选按钮和复选框输入[shiny R]

时间:2019-06-02 01:41:49

标签: r input shiny format rstudio

在我的应用中,我希望用户选择一系列输入并创建一个输出。我已经完成了这项工作,但是我的输入选项占用了大量空间,并且不是很友好。有没有一种方法可以使两者中的一个闪闪发光: 1.缩小/压缩输入大小 2.具有表示为表格的各种输入类型(矩阵样式?)

我尝试使用fluidRow()column()的组合使其看起来像一张桌子。但这需要很多空间。下面是我的代码的一小部分。但是,我有11个这样的行,所有列中的选项都相似。

ui <- navbarPage(
  title = "Dummy",
  tabPanel(
    tags$b("Input table"),
    fluidRow(column(8,
                    textInput("name", h3("Name"), 
                              value = "A"),
                    numericInput("area", "Area", value = 0)
    )),

    hr(),

    fluidRow(column(3,
                    h4("Category")),

             column(2,
                    h4("number1")),
             column(3,
                    h4("checkbox options")),
             column(2,
                    h4("radiobuttons")),
             column(2,
                    h4("number2%"))
    ),
    hr(),

    ### AAAA #####
    fluidRow(column(3,
                    h4("AAAA")),
             column(2,
                    numericInput("aaaal", "", value = 0, max = 100)),
             column(1,
                    checkboxInput("aaaamlc", "selectthis", value= F)),
             column(2,
                    checkboxInput("aaaamli", "selectthis", value= F)),
             column(2,
                    radioButtons("aaaas", "", choices = list("option 1" = 1,
                                                               "option 2" = 2,
                                                               "None" = 3),
                                 selected = 3, inline = F)),
             column(2,
                    numericInput("aaaat", "", value = 0, max = 100))
    ),
    ### BBBB #####
    fluidRow(column(3,
                    h4("BBBB")),
             column(2,
                    numericInput("bbbbl", "", value = 0, max = 100)),
             column(1,
                    checkboxInput("bbbbmlc", "selectthis", value= F)),
             column(2,
                    checkboxInput("bbbbmli", "selectthis", value= F)),
             column(2,
                    radioButtons("bbbbs", "", choices = list("Option 1" = 1,
                                                               "Option 2" = 2,
                                                               "None" = 3), 
                                 selected = 3, inline = F)),
             column(2,
                    numericInput("bbbbt", "", value = 0, max = 100))
    ),

    ### CCCC ####
    fluidRow(column(3,
                    h4("CCCC")),
             column(2,
                    numericInput("ccccl", "", value = 0, max = 100)),
             column(1,
                    checkboxInput("ccccmlc", "Low Cu/Zn", value= F)),
             column(2, h5("")),
             column(2,
                    radioButtons("ccccs", "", choices = list("Option 1" = 1,
                                                                "Option 2" = 2,
                                                                "None" = 3),
                                 selected = 3, inline = F)),
             column(2,
                    numericInput("cccct", "", value = 0, max = 100))
    ),


    ### DDDD ####
    fluidRow(column(3,
                    h4("DDDD")),
             column(2,
                    numericInput("ddddl", "", value = 0, max = 100))
    ),
    hr(),
    ##### final action button ####
    actionButton("do",h3(tags$b("calculate")), 
                 width = "600px"),

    hr()

    ))


server <- function(input, output, session) {
  print("hello")
}

shinyApp(ui = ui, server = server)

0 个答案:

没有答案