我需要一些帮助来解决我试图解决的这个特殊问题。以下是我希望该功能的用途:
以下是我的尝试:
server.R
output$gameMetricsPanels <- renderUI({
# gameMetrics is a data frame of games and metrics being measured
# input$gameSelected is the value that is selected by the user from the dropdown
currentGame <- get_game_code(gameMetrics, input$gameSelected)
# get_metric_groups will return a list of metrics for the selected game
gameMetricGroups <- get_metric_groups(gameMetrics, currentGame)
tabs <- lapply(tools::toTitleCase(gameMetricGroups), tabPanel)
do.call(tabBox, tabs)
ui.R
ui <- dashboardPage(
shinyHeader, # stuff I have for header
shinySidebar, # stuff I have for sidebar
dashboardBody(
tabItems(
tabItem(
tabName = "dashboard",
fluidRow(
column(
12,
uiOutput("gameMetricsPanels")
)
)
)
)
)
)
)
为什么这种方法没有按预期工作:
因为tabBox有一个默认的 width = 6 ,我无法用 do.call 来控制它。我不是R专家,谷歌搜索并没有真正帮助。
server.R
output$gameMetricsPanels <- renderUI({
# gameMetrics is a data frame of games and metrics being measured
# input$gameSelected is the value that is selected by the user from the dropdown
currentGame <- get_game_code(gameMetrics, input$gameSelected)
# get_metric_groups will return a list of metrics for the selected game
gameMetricGroups <- get_metric_groups(gameMetrics, currentGame)
tabs <- list(NULL)
for (gameMetricGroup in gameMetricGroups) {
tab <- tabPanel(toosl::toTitleCase(gameMetricGroup), value = gameMetricGroup)
tabs <<- c(tabs, tab)
}
return(tabs)
ui.R
# stuff similar to above attempt but without the crazy nesting for readability
fluidRow(
column(
12,
tabBox( # Here, the main difference is that I'm wrapping the uiOutput in tabBox but I don't know if that's allowed
id = "tabMetrics",
width = NULL, # enforce width to match parent container
uiOutput("gameMetricsPanels")
)
)
)
为什么这种方法不起作用:
没有任何内容显示为标签...