開始使用免費開始

建立 DTM

使用 tidy_twitter 資料建立文件-詞彙矩陣(DTM)。在這裡,每則推文視為一份文件。請在主控台印出 tidy_twitter,確認欄位名稱。

本練習屬於課程

R 文字分析入門

檢視課程

練習說明

  • 從已整理的 Twitter 資料開始。
  • 針對每則推文統計各單字的出現次數。
  • 使用每則推文的單字計數來建立 DTM。

動手互動練習

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

# Start with the tidied Twitter data
___ %>% 
  # Count each word used in each tweet
  ___(word, ___) %>% 
  # Use the word counts by tweet to create a DTM
  cast_dtm(___, word, n)
編輯並執行程式碼