Building Dashboards with shinydashboard
Png Kee Seng
Researcher
We work for a tour agency in London.
Tourists need a place to stay.
What can we do to help them?
header <- dashboardHeader(
title = "Home rental listings")
sidebar <- dashboardSidebar()
body <- dashboardBody()
ui <- dashboardPage(header,
sidebar,
body)
server <- function(input, output) {}
shinyApp(ui, server)
In body
:
fluidRow(
valueBoxOutput(outputId = "count"),
valueBoxOutput(outputId = "prop"),
valueBoxOutput(outputId = "avg"))
In server
:
output$count <- renderValueBox({
valueBox(..., icon = ...)})
output$prop <- renderValueBox(...)
...
In body
:
box(
side = "right", ...,
sliderInput(inputId = "range",
label = "Select price range:",
min = 0,
max = 25000,
value = c(0,25000))
))
Update server
, using input$range[1]
and input$range[2]
In body
:
plotlyOutput("plots",
height = 500,
width = 600)
In server
:
output$plots <- renderPlotly({
...
})
In body
:
selectInput(inputId = "select",
label = "Select group:",
choices = c("Neighbourhood",
"Room Type"))
In server
:
output$plots <- renderPlotly({
if (input$select == ...){plot1}
else if(input$select == ...){plot2}
})
In body
:
box(side = "right", ...,
title = "Welcome to London!",
"...")
Update in body
:
tabBox(id = "tabset", ...,
tabPanel("Charts", ...),
tabPanel("Data table", ...)
We can use shiny
functions.
In body
:
dataTableOutput("table")
In server
:
output$table <-
renderDataTable(listings)
In sidebar
:
sidebarMenu(
menuItem("Charts", ...),
menuItem("Map", ...))
In body
:
leafletOutput("map",...)
In server
:
output$map <- renderLeaflet(map)
Building Dashboards with shinydashboard