헤더 설정하기
영상에서 헤더는 식당의 간판이나 전면부에 비유되었죠.
헤더에는 shinydashboard의 제목을 정의하고, 추가 요소를 넣을 수 있어요. 특히, 다양한 유형의 항목을 담는 여러 종류의 드롭다운 리스트를 보셨을 거예요.
이 연습에서는 전 세계 축구 토너먼트의 통계를 이미 분석했다고 가정해 보겠습니다. 이제 그 결과를 보여 줄 대시보드를 만들려고 해요. 이를 위해 먼저 헤더를 설정하겠습니다.
shiny와 shinydashboard 패키지는 이미 불러와 두었습니다.
이 연습은 강의의 일부입니다
shinydashboard로 대시보드 만들기
연습 안내
title을 "Analysis results for global soccer tournament"로 설정하세요.- 제목 너비를 400으로 설정하세요.
- type이 "messages"인 드롭다운 리스트를 하나 만들고, 메시지 항목을 하나 포함하세요.
- type이 "notifications"인 드롭다운 리스트를 하나 더 추가하고, 알림 항목 1개와 작업 항목 1개를 포함하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
header <- dashboardHeader(
# Set the title as "Analysis results for global soccer tournament"
___,
# Set the title width to 400
___,
# Add a dropdown menu containing two messages
dropdownMenu(type = ___,
___("Colleague", "Hello world!")),
# Add another dropdown menu containing two other items
___(___,
___("Have you rested today?"),
___("Dashboard completion", value = 20)))
sidebar <- dashboardSidebar(); body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body); server <- function(input, output){}
shinyApp(ui, server)