ap_ldanew1 <- LDA(data, k = 20, control = list(seed = 1234))
ap_documents <- tidy(ap_ldanew1, matrix = "gamma")
ap_documents
ap_top_document <- ap_documents %>%
group_by(document) %>%
top_n(2, gamma) %>%
ungroup() %>%
arrange(gamma)
当我尝试获取我没有得到的每个文档的前3个主题时,我已经在文本数据dtm中应用了lda。它给出了所有主题,但我只希望每个文档的前3个主题。 输出:
doc topic gamma
1 1 0.028921062
2 1 0.028921062
3 1 0.028921062
4 1 0.025357647
5 1 0.033649733
6 1 0.022576016
7 1 0.028921062
8 1 0.028921062
9 1 0.028921062
10 1 0.028921062
11 1 0.033649733
12 1 0.028921062
13 1 0.025357647