【发布时间】:2021-12-17 03:38:14
【问题描述】:
我在下面有一个闪亮的应用程序,带有 3 个不同的选项卡。我希望每个选项卡都有自己的侧边栏,我使用conditionalPanel() 做到了这一点。虽然第一个选项卡 (InsiderTraining) 里面还有 2 个选项卡 (Tab1,Tab2),但我也希望有单独的侧边栏。
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = tags$body(class="skin-blue sidebar-mini control-sidebar-open",dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = dashboardHeader(title = "Investment Advisor Monitoring - Insider Trading",titleWidth = 450),
sidebar = dashboardSidebar(minified = F, collapsed = F,
h4("Investment Selected"),
uiOutput("mytab11"), uiOutput("mytab12"),uiOutput("mytab13"),uiOutput("mytab14")
#textInput("StockTicker3", "Enter Stock Symbol 3", value = "AMZN")
),
body = dashboardBody(
h3('Results'),
tabsetPanel(id = "tabs",
tabPanel("InsiderTraining",
tabsetPanel(id="tabs2",
tabPanel("tab1"),
tabPanel("tab2"))),
tabPanel("Switching"),
tabPanel("Tax Loss Harvesting")
)
),
controlbar = dashboardControlbar(width = 300,
h4("Insider Trading Parameters"),
uiOutput("mytab21"), uiOutput("mytab22")
#selectInput("InsiderTradingModel3", "Insider Trading Model 3",
# c("Dynamic" = "Dynamic",
# "AI based" = "AIbased"))
),
title = "DashboardPage"
)),
server = function(input, output) {
output$mytab11 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="InsiderTraining"',
textInput("StockTicker", "Enter Stock Symbol", value = "NFLX"),
sliderInput('periods','Periods',min=1,max=120,value=60),
selectInput("mtvar", "Choose a variable", choices = colnames(mtcars))
))
})
output$mytab12 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
textInput("StockTicker2", "Enter Stock Symbol", value = "APPL"),
selectInput("cvar", "Choose a variable", choices = colnames(cars))
))
})
output$mytab13 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs2=="Tab1"',
textInput("StockTicker3", "Enter Stock Symbol", value = "APPL"),
selectInput("cvar2", "Choose a variable", choices = colnames(cars))
))
})
output$mytab14 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs2=="Tab2"',
textInput("StockTicker4", "Enter Stock Symbol", value = "APPL"),
selectInput("cvar3", "Choose a variable", choices = colnames(cars))
))
})
}
)
【问题讨论】: