【发布时间】:2020-02-08 02:23:50
【问题描述】:
我是第一次使用 renderUI。当我运行应用程序时,默认情况下没有选择选项卡;在服务器外部定义 UI 时,通常默认选择第一个选项卡。
知道为什么会发生这种情况,或者如何指定在启动时默认选择第一个选项卡吗?
例子:
library(shiny)
library(shinydashboard)
library(tidyverse)
library(DT)
header <- dashboardHeader(title = "header")
sidebar <- dashboardSidebar(uiOutput("sidebar"))
body <- dashboardBody(uiOutput("body"))
ui <- dashboardPage(title = 'Radial Networks', header, sidebar, body, skin='blue')
server <- function(input, output, session){
output$body <- renderUI({
dashboardBody(
tabItems(
tabItem(
tabName = 'Chords', h2(fluidRow(
box(plotOutput('plot'), type = 'html', width = 6, height = '870px')
)))))})
output$sidebar <- renderUI({
dashboardSidebar(sidebarMenu(
menuItem("Radial Networks", tabName = "Chords", icon = icon("adjust"))))
})
output$plot <- renderPlot({
ggplot(mtcars, aes(x = factor(cyl))) +
geom_bar()
})
}
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r shiny shinydashboard