Shiny 中的词云

案例研究:使用 R 的 Shiny 构建 Web 应用

Dean Attali

Shiny Consultant

词云

  • 文本的可视化呈现
  • 大词=常见,小词=少见

Shiny 中的词云.003.png

案例研究:使用 R 的 Shiny 构建 Web 应用

R 中的词云——函数

  • 由您的同事创建:

    create_wordcloud(data, num_words = 100, background = "white")
    
  • data:用于生成词云的文本

    • 单个字符串:
      • data = "Some very long story"
    • 字符串列表:
      • data = c("Some very", "long story")
  • num_words:最大词数

  • background:背景颜色
案例研究:使用 R 的 Shiny 构建 Web 应用

R 中的词云——用法

us_constitution <- "We the People of the United States, ..."

create_wordcloud(data = us_constitution, num_words = 15, background = "yellow")

R 中的词云——用法.012.png

案例研究:使用 R 的 Shiny 构建 Web 应用

词云:从 R 到 Shiny

  • 使用 create_wordcloud() 需要 R 知识
  • 做成 Shiny 应用 ⇒ 任何人都可生成词云
案例研究:使用 R 的 Shiny 构建 Web 应用

Shiny 中的词云

Shiny 中的词云.016.png

  • 词云是新的输出类型
  • wordcloud2Output() + renderWordcloud2()
案例研究:使用 R 的 Shiny 构建 Web 应用

让我们来练习!

案例研究:使用 R 的 Shiny 构建 Web 应用

Preparing Video For Download...