시작하기무료로 시작하기

레이아웃(UI) 업데이트

Shiny에서 제공하는 layout 함수를 사용해 UI 요소를 배치할 수 있어요. 여기서는 입력을 sidebarPanel() 안에, 출력을 mainPanel() 안에 배치하는 sidebarLayout()을 사용하겠습니다. 아래 템플릿을 참고해 앱의 레이아웃을 업데이트해 보세요.

sidebarLayout(
  sidebarPanel(p("This goes into the sidebar on the left")),
  mainPanel(p("This goes into the panel on the right"))
)

shinyggplot2 패키지는 미리 불러와 두었습니다. 참고로, p('hello')는 텍스트 "hello"가 들어간 HTML 문단을 반환합니다.

이 연습은 강의의 일부입니다

R로 Shiny 웹 애플리케이션 만들기

강의 보기

연습 안내

  • textInput()sidebarPanel() 안에 배치하세요.
  • plotOutput()mainPanel() 안에 배치하세요.
  • 두 패널을 사이드바 레이아웃에 넣으세요: sidebarLayout(___ , ___).

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

ui <- fluidPage(
  titlePanel("Baby Name Explorer"),
  # CODE BELOW: Add a sidebarLayout, sidebarPanel, and mainPanel
  
  textInput('name', 'Enter Name', 'David'),
  plotOutput('trend')
  
)

server <- function(input, output, session) {
  output$trend <- renderPlot({
    ggplot()
  })
}

shinyApp(ui = ui, server = server)
코드 편집 및 실행