開始使用免費開始

將 DTM 當作矩陣來評估

來練習把整潔化的資料轉換成 DTM,並把 DTM 視為矩陣來評估。

在這個練習中,你會再次建立 DTM,但使用的是更小的一部分 twitter 資料(tidy_twitter_subset)。

本練習屬於課程

R 文字分析入門

檢視課程

練習說明

  • 將每則推文中的字詞計數轉換為 DTM,指定為 dtm_twitter
  • dtm_twitter 強制轉型為名為 matrix_twitter 的矩陣。
  • 列印第 1 到第 5 列,以及第 90 到第 95 欄。

動手互動練習

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

# Assign the DTM to dtm_twitter
dtm_twitter <- tidy_twitter_subset %>% 
  count(word, tweet_id) %>% 
  # Cast the word counts by tweet into a DTM
  ___(___)

# Coerce dtm_twitter into a matrix called matrix_twitter
___ <- ___(___)

# Print rows 1 through 5 and columns 90 through 95
___
編輯並執行程式碼