
6.2
例:図書館荒らし
■
115
## 3 Great Expectations_17 biddy 63
## 4 Great Expectations_27 joe 58
## 5 Great Expectations_38 estella 58
## 6 Great Expectations_2 joe 56
## 7 Great Expectations_23 pocket 53
## 8 Great Expectations_15 joe 50
## 9 Great Expectations_18 joe 50
## 10 The War of the Worlds_16 brother 50
## # ... with 104,711 more rows
6.2.1
章を対象とする
LDA
word_counts
デ ー タ フ レ ー ム は、
1
行 に
1
つ の 文 書 と 単 語 の 組 み 合 わ せ と い
う 整 理 形 式 に な っ て い ま す が、
topicmodels
パ ッ ケ ー ジ が 対 応 し て い る の は
DocumentTermMatrix
です。そこで、「5.2 整理データの行列へのキャスト」で説明し
たように、
tidytext
の
cast_dtm()
を使って
1
行
1
トークンの表を
DocumentTermMatrix
にキャストします。
chapters_dtm <- word_counts %>%
cast_dtm(document, word, n)
chapters_dtm ...