shinydashboard로 대시보드 만들기
Png Kee Seng
Researcher
dashboardBody()로 정의하고 관례적으로 body에 저장합니다body <- 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)))))
width를 설정합니다box() 추가를 권장합니다
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()와 infoBox()의 변형:
valueBoxOutput() 및 infoBoxOutput()renderValueBox()와 renderInfoBox()도 있습니다valueBox()와 infoBox()가 필요합니다
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() 객체 포함valueBoxOutput():renderValueBox():server()에 배치valueBox() 객체 포함tabItems()를 추가해야 합니다tabItem()으로 정의menuItem()-tabItem() 쌍의 라벨이 일치해야 합니다
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()와 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")) }
shinydashboard로 대시보드 만들기