As far as I know, this could be achieved in two ways.
- Simple shiny app:
You can create tabs using tabPanel(title, ...)
function and then wrapping all the tabPanel()
s inside a tabsetPanel()
function.
So, in your case you can put all the UI elements of your first app inside the first tabPanel('unique_title')
and so on.
This will help you create multiple independently viewable sections.
You can refer these two links to know more
http://shiny.rstudio.com/reference/shiny/latest/tabPanel.html
- As @Michal suggested, using
shinydashboard
:
shinydashnoard
is another package that you will have to install in order to use this feature of shiny. It basically has a predefined structure with a header, a sidebar and a body.
The basic structure is shown below:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashbaordSidebar(),
dashboardBody()
)
server <- function(input,output,server){...}
Normally, dashboardSidebar()
is used for navigation. However, it can contain menuItem()
that behave like tabs in a tabPanel()
.
For your case, you can add multiple menuItem()
s inside sidebarMenu()
as shown below
Updated Code
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("first_app", tabName = "first_app"),
menuItem("second_app", tabName = "second_app")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "first_app",
h2("First App Content")
),
tabItem(tabName = "second_app",
h2("Second App Content"))
)
)
)
server <- function(input,output,server){}
shinyApp(ui,server)
This will create a basic dashboard page with 2 menu items.
You can also refer to link below to know more about the shinydashboard structure
https://rstudio.github.io/shinydashboard/structure.html
I hope this helps :)