Building Dashboards with shinydashboard
Png Kee Seng
Researcher
dashboardBody() and is conventionally stored as bodybody <- dashboardBody(...)

fluidRow()box()
body <- dashboardBody(fluidRow(box("Row 1, box 1"), box("Row 1, box 2")), fluidRow(box("Row 2, box 1"), box("Row 2, box 2")))

body <- dashboardBody( fluidRow(box("Row 1, box 1",plotOutput('plot')),box("Row 1, box 2")), fluidRow(box("Row 2, box 1"), box("Row 2, box 2",selectInput("select", "Select team number:", choices = c(1,2)))))
widthbox()'s is highly recommended
body <- dashboardBody(
fluidRow(box("Row 1, box 1"),
box("Row 1, box 2"),
box("Row 1, box 3")),
fluidRow(box("Row 2, box 1"),
box("Row 2, box 2"))
)
body <- dashboardBody(
fluidRow(box("Row 1, box 1", width = 3),
box("Row 1, box 2", width = 5),
box("Row 1, box 3", width = 4)),
fluidRow(box("Row 2, box 1"),
box("Row 2, box 2"))
)
valueBox()infoBox()
body <- dashboardBody( fluidRow(valueBox(value = 3, subtitle = "Total no. of red cards awarded", icon = icon("user"), color = "red"),infoBox(value = 158, title = "Total no. of goals scored", icon = icon("futbol")) ))
valueBox() and infoBox():
valueBoxOutput() and infoBoxOutput()renderValueBox() and renderInfoBox()valueBox() and infoBox() are needed
body <- dashboardBody(
fluidRow(valueBoxOutput(outputId = "valuebox1"),
infoBoxOutput(outputId = "infobox1")
))
server <- function(input, output){
output$valuebox1 <- renderValueBox(
valueBox(3, "Total no. of red cards awarded",
icon = icon("user"), color = "red"))
output$infobox1 <- renderInfoBox(
infoBox(158,
title = "Total no. of goals scored",
icon = icon("futbol")))
}
plotOutput():renderPlot():server()ggplot() objectvalueBoxOutput():renderValueBox():server()valueBox() objecttabItems()tabItem()menuItem()-tabItem() pair must match
sidebar <- dashboardSidebar( sidebarMenu( id = "pages",menuItem("Many charts", tabName = "charts", icon = icon("chart-line"), badgeLabel = "New content!", badgeColor = "green"),menuItem("Statistics", icon = icon("file-excel"), tabName = "statistics", badgeLabel = "urgent", badgeColor = "red") ))body <- dashboardBody( tabItems(tabItem("charts", "Charts go here." ), tabItem("statistics", "Statistics go here." )))
tabsetPanel()tabPanel()tabItems() and tabItem()
body <- dashboardBody(tabsetPanel(tabPanel("Distributions", box(plotOutput("dist"))), tabPanel("Statistics", dateInput("matchdate", "Enter the match date:", value = "2022-11-20"), valueBoxOutput("red"), valueBoxOutput("yellow")), tabPanel("Data", "Data goes here.", tableOutput("data"))))server <- function(input, output){ output$red <- renderValueBox(valueBox(0, "Red cards")) output$yellow <- renderValueBox(valueBox(6, "Yellow cards")) }
Building Dashboards with shinydashboard