I was wondering if I could modify the following shiny app and put the sliderInput into the sidebar section :
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "DB manager"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard",
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
),
# Second tab content
tabItem(tabName = "widgets",
h2("Widgets tab content")
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
Something like :
Below I have used the menuItem inside menuItem. for the first sleider, I can see the plot but for the second I can not !
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "DB manager"),
dashboardSidebar(
# sidebarMenu(
# menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"),
# sliderInput("slider", "Number of observations:", 1, 100, 50)),
# menuItem("Widgets", tabName = "widgets", icon = icon("th"))
# )
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard"),
sliderInput("slider", "Number of observations:", 1, 100, 50),
menuItem("", tabName = "dashboard2")
),
menuItem("Widgets", tabName = "widgets", icon = icon("th"),
sliderInput("slider1", "Number of observations:", 1, 100, 50),
menuItem("", tabName = "dashboard3"))
)
),
dashboardBody(
tabItems(
# First tab content
tabItem(tabName = "dashboard2",
fluidRow(
box(plotOutput("plot1", height = 250))
)
),
# Second tab content
tabItem(tabName = "dashboard3",
fluidRow(
box(plotOutput("plot2", height = 250))
)
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot2 <- renderPlot({
data <- histdata[seq_len(input$slider1)]
hist(data)
})
}
shinyApp(ui, server)
Any Idea how I could achieve that ?