I want to be able to create multiple pages each with a set of widgets drop down, radio button and a space to plot a map. The Shiny tutorial shows how to create multiple pages
shinyUI(navbarPage("My Application",
tabPanel("Component 1"),
tabPanel("Component 2"),
tabPanel("Component 3")
))
How can I add widgets in each page for e.g. how can I add the following to Component 1?
sidebarLayout(
sidebarPanel(
selectizeInput(
'id', label = "Year", choices = NULL,multiple=FALSE,selected="X2015",
options = list(create = TRUE,placeholder = 'Choose the year')
),
# Make a list of checkboxes
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1,
"Choice 2" = 2)
and
mainPanel(
plotOutput("distPlot")
)
You should probably read the reference page of tabPanel
: http://shiny.rstudio.com/reference/shiny/latest/tabPanel.html
shinyUI(
navbarPage("My Application",
tabPanel(
"Component 1",
sidebarLayout(
sidebarPanel(
selectizeInput(
'id', label="Year", choices=NULL, multiple=F, selected="X2015",
options = list(create = TRUE,placeholder = 'Choose the year')
),
# Make a list of checkboxes
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1, "Choice 2" = 2)
)
),
mainPanel( plotOutput("distPlot") )
)
),
tabPanel("Component 2"),
tabPanel("Component 3")
)
)
You could do tabPanel("Component 1", ...)
, replacing the dots with all of your sidebarPanel
code. Or, use renderUI
on the server side,
library(shiny)
shinyApp(
shinyUI(
navbarPage("My Application",
tabPanel("Component 1", uiOutput('page1')),
tabPanel("Component 2"),
tabPanel("Component 3")
)
),
shinyServer(function(input, output, session) {
output$page1 <- renderUI({
sidebarLayout(
sidebarPanel(
selectizeInput(
'id', label = "Year", choices = NULL,multiple=FALSE,selected="X2015",
options = list(create = TRUE,placeholder = 'Choose the year')
),
## Make a list of checkboxes
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1, "Choice 2" = 2))
),
mainPanel(
plotOutput('distPlot')
)
)
})
output$distPlot <- renderPlot({ plot(1) })
})
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With