我正在尝试绘制诸如https://rpubs.com/Alexreda/224494这样的主题和推文日期的密度图。
但是,删除dtm的空行之后,我无法找到一种方法来删除相应的日期。
dtm <- as.DocumentTermMatrix(tdm)
rowTotals <- apply(dtm , 1, sum) #Find the sum of words in each Document
dtm.new <- dtm[rowTotals> 0, ] #remove all docs without words
lda <- LDA(dtm.new, k = 4) # find 4 topics
term <- terms(lda, 4) # first 4 terms of every topic
(term <- apply(term, MARGIN = 2, paste, collapse = ", "))
topics <- topics(lda)
topics <- data.frame(date=mynegativedata$tweet_created, topic = topics)
ggplot(topics, aes(date, fill = term[topic])) +
geom_density(position = "stack") +
theme(legend.position=c(0.2, 0.8))
因此我遇到以下错误:
data.frame中的错误(日期= mynegativedata $ tweet_created,topic = 主题):参数暗示的行数不同:9000、8992
感谢您的帮助。谢谢!!