Xây dựng Dashboard với shinydashboard
Png Kee Seng
Researcher
Chúng ta làm cho một hãng du lịch ở London.
Khách du lịch cần chỗ ở.
Ta có thể giúp gì?


header <- dashboardHeader(
title = "Home rental listings")
sidebar <- dashboardSidebar()
body <- dashboardBody()
ui <- dashboardPage(header,
sidebar,
body)
server <- function(input, output) {}
shinyApp(ui, server)
Trong body:
fluidRow(
valueBoxOutput(outputId = "count"),
valueBoxOutput(outputId = "prop"),
valueBoxOutput(outputId = "avg"))
Trong server:
output$count <- renderValueBox({
valueBox(..., icon = ...)})
output$prop <- renderValueBox(...)
...
Trong body:
box(
side = "right", ...,
sliderInput(inputId = "range",
label = "Chọn khoảng giá:",
min = 0,
max = 25000,
value = c(0,25000))
))
Cập nhật server, dùng input$range[1] và input$range[2]

Trong body:
plotlyOutput("plots",
height = 500,
width = 600)
Trong server:
output$plots <- renderPlotly({
...
})

Trong body:
selectInput(inputId = "select",
label = "Chọn nhóm:",
choices = c("Neighbourhood",
"Room Type"))
Trong server:
output$plots <- renderPlotly({
if (input$select == ...){plot1}
else if(input$select == ...){plot2}
})
Trong body:
box(side = "right", ...,
title = "Chào mừng đến London!",
"...")
Cập nhật trong body:
tabBox(id = "tabset", ...,
tabPanel("Biểu đồ", ...),
tabPanel("Bảng dữ liệu", ...)

Ta có thể dùng các hàm shiny.
Trong body:
dataTableOutput("table")
Trong server:
output$table <-
renderDataTable(listings)

Trong sidebar:
sidebarMenu(
menuItem("Biểu đồ", ...),
menuItem("Bản đồ", ...))
Trong body:
leafletOutput("map",...)
Trong server:
output$map <- renderLeaflet(map)
Xây dựng Dashboard với shinydashboard