I have the shiny app below with 3 different tabs, a sidebar and a right sidebar. I would like every time that I move to another tab the content of the right sidebar to change and display different widgets. In the third though named "Tax Loss Harvesting" I want to add a controlbarMenu()
. How can I make it be displayed only when Im in the third tab?
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")
),
body = dashboardBody(
h3('Results'),
tabsetPanel(id = "tabs",
tabPanel("InsiderTraining"),
tabPanel("Switching"),
tabPanel("Tax Loss Harvesting")
)
),
controlbar = dashboardControlbar(width = 300,
#controlbarMenu(
# id = "menu",
#controlbarItem(
# "Tab 1",
#"Welcome to tab 1"
#),
#controlbarItem(
# "Tab 2",
#"Welcome to tab 2"
#)
#)
h4("Insider Trading Parameters"),
uiOutput("mytab21"), uiOutput("mytab22"),uiOutput("mytab23")
),
title = "DashboardPage"
)),
server = function(input, output) {
output$mytab21 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="InsiderTraining"',
selectInput("InsiderTradingModel", "Insider Trading Model",
c("Dynamic" = "Dynamic",
"AI based" = "AIbased")),
#textInput("StockTicker", "Enter Stock Symbol", value = "NFLX"),
selectInput("ivar", "Choose a variable", choices = colnames(iris))
))
})
output$mytab22 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
selectInput("InsiderTradingModel2", "Insider Trading Model 2",
c("Dynamic" = "Dynamic",
"BI based" = "BIbased")),
sliderInput('periodss','Periods',min=1,max=100,value=30),
selectInput("pvar", "Choose a variable", choices = colnames(pressure))
))
})
output$mytab23 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
))
})
}
)
Perhaps you are looking for this
menu <- controlbarMenu(
id = "controlbarMenu",
controlbarItem(
"Tab 1",
"Welcome to tab 1"
),
controlbarItem(
"Tab 2",
numericInput("num", "Observations:", 200, min = 1, max = 1000, step = 100)
)
)
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")
#textInput("StockTicker3", "Enter Stock Symbol 3", value = "AMZN")
),
body = dashboardBody(
h3('Results'),
tabsetPanel(id = "tabs",
tabPanel("InsiderTraining"),
tabPanel("Switching"),
tabPanel("Tax Loss Harvesting")
)
),
controlbar = dashboardControlbar(width = 300,
h4("Insider Trading Parameters"),
uiOutput("mytab21"), uiOutput("mytab22"), uiOutput("mytab32")
#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$mytab21 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="InsiderTraining"',
selectInput("InsiderTradingModel", "Insider Trading Model",
c("Dynamic" = "Dynamic",
"AI based" = "AIbased")),
#textInput("StockTicker", "Enter Stock Symbol", value = "NFLX"),
selectInput("ivar", "Choose a variable", choices = colnames(iris))
))
})
output$mytab22 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Switching"',
selectInput("InsiderTradingModel2", "Insider Trading Model 2",
c("Dynamic" = "Dynamic",
"BI based" = "BIbased")),
sliderInput('periodss','Periods',min=1,max=100,value=30),
selectInput("pvar", "Choose a variable", choices = colnames(pressure))
))
})
output$mytab32 <- renderUI({
tagList(
conditionalPanel(condition = 'input.tabs=="Tax Loss Harvesting"',
selectInput("pvar", "Choose a variable", choices = colnames(rock)),
menu
))
})
}
)