開始使用免費開始

繪製更好的文字雲

既然你已經移除了更多停用詞,來看看改良後的文字雲吧!

前一個練習中的詞彙-文件矩陣已用 as.matrix() 轉為矩陣,接著以 rowSums() 建立了一個具名向量。這個新的詞頻物件名為 chardonnay_words,已預先載入到你的工作空間。讓我們來看看這些新的文字雲結果。

本練習屬於課程

R 的 Bag-of-Words 文本探勘

檢視課程

練習說明

我們已在背景替你載入 wordcloud 套件,之後所有需要它的練習也都會自動載入。

  • chardonnay_words 的值排序,設定 decreasing = TRUE。儲存為 sorted_chardonnay_words
  • 檢視 sorted_chardonnay_words 的前 6 個字詞及其值。
  • 使用 names() 套用在 chardonnay_words 上建立 terms_vec
  • terms_vecchardonnay_words 傳入 wordcloud() 函式。檢視在移除「chardonnay」之後,現在還有哪些字詞更突出。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Sort the chardonnay_words in descending order
___ <- ___(___, ___)

# Print the 6 most frequent chardonnay terms
___(___)

# Get a terms vector
___ <- ___(___)

# Create a wordcloud for the values in word_freqs
wordcloud(___, ___, 
          max.words = 50, colors = "red")
編輯並執行程式碼