我使用renderUI
生成大量输入,我希望在tabPanel中有一个多列显示。
当然输入的数量是动态的: - )
知道如何做到这一点?
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
),
mainPanel(
tabsetPanel(
tabPanel("Plot",
uiOutput("lot_of_input")
),
tabPanel("Summary", verbatimTextOutput("summary"))
)
)
)
)
server <- function(input, output) {
output$lot_of_input <- renderUI({
list(
numericInput(inputId = "A","A",1),
numericInput(inputId = "AB","AB",1),numericInput(inputId = "B","C",1),
numericInput(inputId = "C2","C",1),
numericInput(inputId = "A3","A",1),
numericInput(inputId = "AB3","AB",1),
numericInput(inputId = "B3","C",1),
numericInput(inputId = "C23","C",1)#, lot of other input
) # In my code this list is returned by a function
})
output$summary <- renderText("coucou")
}
# Run the application
shinyApp(ui = ui, server = server)
答案 0 :(得分:3)
只需将您的列表与split
分成2,如果订单有问题,您可以在sort
中f
split
参数:
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
),
mainPanel(
tabsetPanel(
tabPanel("Plot",
uiOutput("lot_of_input")
),
tabPanel("Summary", verbatimTextOutput("summary"))
)
)
)
)
server <- function(input, output) {
output$lot_of_input <- renderUI({
x <- list(
numericInput(inputId = "A","A",1),
numericInput(inputId = "AB","AB",1),numericInput(inputId = "B","C",1),
numericInput(inputId = "C2","C",1),
numericInput(inputId = "A3","A",1),
numericInput(inputId = "AB3","AB",1),
numericInput(inputId = "B3","C",1),
numericInput(inputId = "C23","C",1),
numericInput(inputId = "C24","C",1)
)
fluidRow(
lapply(
X = split(x, f = rep(c(1, 2), length.out = length(x))),
FUN = column, width = 6
)
)
})
output$summary <- renderText("coucou")
}
shinyApp(ui = ui, server = server)
答案 1 :(得分:1)
这感觉就像数据操作问题,所以这里有一个使用main.php
的选项:
'notificationManager' => [
'class' => '\admin\components\NotificationManager'
]
然后在输出中使用
dplyr
答案 2 :(得分:0)
ViewHolder
和fluidRow
应相应地安排,如下所示:
column
您可以通过调整list(
fluidRow(
column(3,
numericInput(inputId = "A","A",1)),
column(3,
numericInput(inputId = "C2","C",1))
),
fluidRow(
column(3,
numericInput(inputId = "AB","AB",1)),
column(3,
numericInput(inputId = "A3","A",1))
),
fluidRow(
column(3,
numericInput(inputId = "B","C",1)),
column(3,
numericInput(inputId = "AB3","AB",1))
),
fluidRow(
column(3,
numericInput(inputId = "B3","C",1)),
column(3,
numericInput(inputId = "C23","C",1))
)
)
的宽度并在一个column
中添加更多输入来在一行中添加更多列。