시작하기무료로 시작하기

텍스트 파일 업로드 (ui)

긴 텍스트를 입력 상자에 직접 타이핑하는 대신, 텍스트가 매우 길다면 텍스트 파일을 업로드하는 편이 더 편리할 수 있어요.

Shiny 앱에서 파일 업로드는 fileInput()을 사용해 수행합니다.

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

사례 연구: R의 Shiny로 웹 애플리케이션 만들기

강의 보기

연습 안내

입력 ID가 "file"이고 라벨이 "Select a file"인 파일 입력을 Shiny 앱에 추가하세요.

실습형 인터랙티브 연습

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

ui <- fluidPage(
  h1("Word Cloud"),
  sidebarLayout(
    sidebarPanel(
      textAreaInput("text", "Enter text", rows = 7),
      # Add a file input
      ___,
      numericInput("num", "Maximum number of words",
                   value = 100, min = 5),
      colourInput("col", "Background color", value = "white")
    ),
    mainPanel(
      wordcloud2Output("cloud")
    )
  )
)

server <- function(input, output) {
  output$cloud <- renderWordcloud2({
    create_wordcloud(input$text, num_words = input$num,
                     background = input$col)
  })
}

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