排列 R shiny 侧栏对象

Arrange R shiny Side bar objects

我使用 R shiny 创建了以下界面。

  library(shiny)




  ui <- fluidPage(
  #Can be fluid row also
  fluidRow(
  column(3,
       h3("Excel DB"),
       hr(),
       fileInput("file1", "Excel DB",
                 multiple = TRUE,
                 accept = c("text/csv/xlsx/xls",
                            "text/comma-separated-values,text/plain",
                            ".csv", ".xls", ".xlsx")),
       textInput(inputId = 'Type',label =  'Type'),
       textInput(inputId = 'Client',label =  'Client'),
       textInput(inputId = "Task", label = "Task"),
       actionButton(inputId = "ClearAll", label = "Clear Screen"),
       radioButtons("dist", "Vertical Axis Scale",
                    c("Linear" = "Linear Regression",
                      "Log" = "Logistic Regression"))
),
column(5,h5('              '),
       hr(), downloadButton(outputId = "Downloaddata", label = "Fetch Dataset"),
       textInput(inputId = "Commodity", label = "Commodity"),
       textInput(inputId = "Year", label = "Year"),
       radioButtons("dist", "Horizontal Axis Scale",
                    c("Linear" = "Linear Regression",
                      "Log" = "Logistic Regression")),
       numericInput(inputId = "Numberinput", label = "Numinput", min = -1000000000, max = 1000000000, value = 0,step = 1)

)
), sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, step 
= 2.5, value = 1)
)

我创建了以下空服务器

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

上面的代码创建了一个闪亮的应用程序,它的侧边栏面板有两列。但是,这两列彼此不对齐。我想知道如何安排应用程序的组件如下。

获取数据集按钮应该在浏览按钮旁边。同样,商品文本框应紧挨着类型文本框,年份框应靠近客户。两组单选按钮应相互对齐。我在这里请求一些帮助。我无法按照那种模式排列它们

为此,您需要对 column()fluidRow() 进行一些嵌套。 This answer should explain enough to get you started, along with the examples on Shiny's layout guide。我相信以下内容应该可以大致满足您的需求:

library(shiny)

ui <- fluidPage(
  #Can be fluid row also
  h3("Excel DB"),
  hr(),
  fluidRow(
    column(12,
           fluidRow(
             column(3,
                    fileInput("file1", NULL,
                              multiple = TRUE,
                              accept = c("text/csv/xlsx/xls",
                                         "text/comma-separated-values,text/plain",
                                         ".csv", ".xls", ".xlsx"))),
             column(5,
                    column(3,
                           downloadButton(outputId = "Downloaddata", label = "Fetch Dataset")),
                    column(2, offset = 2,
                           actionButton(inputId = "ClearAll", label = "Clear Screen"))
                    )
           ),
           fluidRow(
             column(3,
                    textInput(inputId = 'Type',label =  'Type'),
                    textInput(inputId = 'Client',label =  'Client'),
                    textInput(inputId = "Task", label = "Task")
             ),
             column(5,
                    textInput(inputId = "Commodity", label = "Commodity"),
                    textInput(inputId = "Year", label = "Year"),
                    numericInput(inputId = "Numberinput", label = "Numinput", min = -1000000000, max = 1000000000, value = 0,step = 1)
             )),
           fluidRow(
             column(3,
                    radioButtons("dist", "Vertical Axis Scale",
                                 c("Linear" = "Linear Regression",
                                   "Log" = "Logistic Regression"))),
             column(5,
                    radioButtons("dist", "Horizontal Axis Scale",
                                 c("Linear" = "Linear Regression",
                                   "Log" = "Logistic Regression")))
             ),
           fluidRow(
             column(5,
                    sliderInput(inputId = "Scale", label = "Scale", min = 0, max = 100, 
                                step = 2.5, value = 1)) 
             )
           )
    )
  )

reprex package (v0.2.1)

于 2018-09-20 创建