Installation
install.packages("shinydashboard")
Layout
A dashboard has three parts. a dashboardHeader( ) , a dashboardSidebar( ) and a dashboardBody( ) .
library(shiny)
library(shinydashboard)
ui = dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody()
)
server = function(input, output) { }
shinyApp(ui, server)
Header
library(shiny)
library(shinydashboard)
ui = dashboardPage(
dashboardHeader(title = "Web App",
tags$li(class="dropdown",tags$a(href="https://github.com/Prachi-Gore",
icon("github"),target="_blank")),
tags$li(class="dropdown",tags$a(href="https://www.linkedin.com/in/prachi-gore-4772a11a5",
icon("linkedin"),target="_blank"))),
dashboardSidebar(),
dashboardBody()
)
server = function(input, output) { }
shinyApp(ui, server)
Body
library(shiny)
library(shinydashboard)
ui_hist = fluidPage(
titlePanel("title panel"),
sidebarLayout(
sidebarPanel("sidebar panel",
numericInput(inputId = "n",label = "Enter Sample Size :",
value = 50)),
mainPanel(plotOutput("histogram"))
)
)
ui = dashboardPage(
title="dashboard page",
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
id = "tabs",
menuItem("Graph", tabName = "graph",
menuSubItem("Histogram", tabName = "histogram")
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "histogram",ui_hist)
)
)
)
server=function(input,output){
size= reactive({input$n})
output$histogram=renderPlot({hist(rnorm(size()))})
}
shinyApp(ui, server)