尝试在 R Shiny 应用程序中的一行中显示多个输入

Trying to display multiple inputs on a single line in an R Shiny app

我有一个正在构建的 R Shiny 应用程序,其中包含多个输入选项。我希望三个 numericInput 选项出现在一行中,每个选项大约占 space 的三分之一。我已经寻找了几个答案,但似乎找不到一个简单的答案。下面是 Shiny 应用程序的 UI 部分 - 关于如何让它们在同一条线上有什么想法吗?

if(interactive()){

    ## load required packages
    library(shiny)
    library(tidyverse)
    library(dplyr)

    ui <- fluidPage(
        titlePanel("2020 Fantasy Football Draft Evaluator"),
        sidebarLayout(
            sidebarPanel(id = "tPanel",style = "overflow-y:scroll; max-height: 600px; position:relative;",
                p(strong("1. Select draft settings")),
                numericInput(inputId = "pass_td_pts",
                             label = "Pass TDs",
                             value = 4,
                             min = 0,
                             max = 8,
                             step = 0.5,
                             width = '33%'),
                numericInput(inputId = "pass_yd_pts",
                             label = "Passing Yards",
                             value = 0.04,
                             min = 0,
                             max = 1,
                             step = 0.01,
                             width = '33%'),
                numericInput(inputId = "int_pts",
                             label = "Interceptions",
                             value = -2,
                             min = -5,
                             max = 5,
                             step = 1,
                             width = '33%'),
                numericInput(inputId = "rush_td_pts",
                             label = "Rushing TDs",
                             value = 6,
                             min = 0,
                             max = 10,
                             step = 1,
                             width = '33%'),
                numericInput(inputId = "rush_yd_pts",
                             label = "Rushing Yards",
                             value = 0.1,
                             min = 0,
                             max = 1,
                             step = 0.1,
                             width = '33%'),
                numericInput(inputId = "fum_pts",
                             label = "Fumbles Lost",
                             value = -2,
                             min = -5,
                             max = 5,
                             step = 1,
                             width = '33%'),
                numericInput(inputId = "rec_td_pts",
                             label = "Receiving TDs",
                             value = 6,
                             min = 0,
                             max = 10,
                             step = 1,
                             width = '33%'),
                numericInput(inputId = "rec_yd_pts",
                             label = "Receiving Yards",
                             value = 0.1,
                             min = 0,
                             max = 1,
                             step = 0.1,
                             width = '33%'),
                numericInput(inputId = "rec_pts",
                             label = "Recptions",
                             value = 0.5,
                             min = 0,
                             max = 2,
                             step = 0.05,
                             width = '33%'),
            mainPanel(
                plotOutput("draftPlot")
            )
        )
    )

fluidRow 可以。

例如将前三个numericInput放在同一行:

if(interactive()){

    ## load required packages
    library(shiny)
    library(tidyverse)
    library(dplyr)

    ui <- fluidPage(
        titlePanel("2020 Fantasy Football Draft Evaluator"),
        sidebarLayout(
            sidebarPanel(id = "tPanel",style = "overflow-y:scroll; max-height: 600px; position:relative;",
                p(strong("1. Select draft settings")),
                fluidRow(
                    column(4, numericInput(inputId = "pass_td_pts",
                             label = "Pass TDs",
                             value = 4,
                             min = 0,
                             max = 8,
                             step = 0.5,
                             width = '33%')),
                    column(4, numericInput(inputId = "pass_yd_pts",
                             label = "Passing Yards",
                             value = 0.04,
                             min = 0,
                             max = 1,
                             step = 0.01,
                             width = '33%')),
                    column(4, numericInput(inputId = "int_pts",
                             label = "Interceptions",
                             value = -2,
                             min = -5,
                             max = 5,
                             step = 1,
                             width = '33%'))),
            mainPanel(
                plotOutput("draftPlot")
            )
        )
    )

然后你可以有另外两个 fluidrow() 作为剩余输入。