如何在Shiny中使用自己的一组小部件创建多个页面

Tin*_*esh 2 r shiny

我希望能够创建多个页面,每个页面都有一组小部件下拉,单选按钮和绘制地图的空间.Shiny教程展示了如何创建多个页面

shinyUI(navbarPage("My Application",
  tabPanel("Component 1"),
  tabPanel("Component 2"),
  tabPanel("Component 3")
))
Run Code Online (Sandbox Code Playgroud)

如何在每个页面中添加小部件,例如如何将以下内容添加到组件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)
Run Code Online (Sandbox Code Playgroud)

     mainPanel(
        plotOutput("distPlot")
    )
Run Code Online (Sandbox Code Playgroud)

use*_*763 5

您应该阅读以下参考页面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")
  )
)
Run Code Online (Sandbox Code Playgroud)