gpt4 book ai didi

r - 在 Shinydashboard 标题上放置一个下拉按钮以进行主题选择

转载 作者:行者123 更新时间:2023-12-04 10:04:45 25 4
gpt4 key购买 nike

我想在 Shinydashboard 标题上放置一个下拉菜单以更改仪表板主题。我 Shiny 的应用程序如下所示。我无法使应用程序工作。我得到的是错误信息;

Error in FUN(X[[i]], ...) : Expected tag to be of type li

仪表板区域似乎不接受那些典型的 Shiny 小部件?标题区域是放置此功能的最佳位置。有谁知道我怎样才能做到这一点?非常感谢。
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(dashboardthemes)


header <- dashboardHeader(
title = "Dashboard Demo",
dropdownButton(

tags$h3("List of Themes:"),

radioButtons(inputId = 'theme',
label = 'Dashboard Theme',
choices = c('blue_gradient', 'boe_website', 'grey_light','grey_dark',
'onenote', 'poor_mans_flatly', 'purple_gradient'),
selected = 'grey_dark',
inline=FALSE),

circle = TRUE, status = "primary",
icon = icon("window-maximize"), width = "300px",

tooltip = tooltipOptions(title = "Click to change dashboard theme")
)
)

shinyApp(
ui = dashboardPage(
header,
dashboardSidebar(),
dashboardBody(
shinyDashboardThemes(
theme = input$theme
),
)
),
server = function(input, output) { }
)

最佳答案

你不能把dropdownButtondashboardHeader .

相反,您可以将其放入 dashboardBodydashboardSidebar并像这样更新:

library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(dashboardthemes)

shinyApp(
ui = dashboardPage(
dashboardHeader(title = "Dashboard Demo"),
dashboardSidebar(),
dashboardBody(
dropdownButton(
radioButtons(inputId = 'theme',
label = 'Dashboard Theme',
choices = c('blue_gradient', 'boe_website', 'grey_light','grey_dark',
'onenote', 'poor_mans_flatly', 'purple_gradient'))
),
uiOutput("myTheme")
)
),
server = function(input, output) {
output$myTheme <- renderUI( shinyDashboardThemes(theme = input$theme))
}
)

关于r - 在 Shinydashboard 标题上放置一个下拉按钮以进行主题选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61645081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com