数据主题建模

时间:2016-09-08 07:41:26

标签: r

dtm <- as.DocumentTermMatrix(tdm)
rowTotals <- apply(dtm , 1, sum) #Find the sum of words in each Document
dtm.new   <- dtm[rowTotals> 0, ]
lda <- LDA(dtm.new, k=8) 
term <- terms(lda, 7) # first 7 terms of every topic
(term <- apply(term, MARGIN = 2, paste, collapse = ", "))
tweets.df$created<- rownames(tweets.df)
melt(tweets.df)
topics<- topics(lda)
topics<- data.frame(date=as.POSIXct(tweets.df$created,format = "%d-%m-%Y"),topic = topics)
qplot(as.character.Date(date), ..count.., data= topics, geom = "density",fill= term[topic], position= "stack")

topics<- data.frame(date=as.POSIXct(tweets.df$created,format = "%d-%m-%Y"),    topic = topics)
Error in data.frame(date = as.POSIXct(tweets.df$created, format = "%d-%m-%Y"),  : 
  arguments imply differing number of rows: 11225, 11223

我收到上面的错误,我最初是从csv文件中读取数据。但它以某种方式抛出错误。我还使用了melt()包中的reshape2函数。请帮忙。

0 个答案:

没有答案