0
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

I am getting the error above, I am reading the data from a csv file initially. But it somehow throws an error. I also used the melt() function from reshape2package. Please help.

  • It seems that `tweets.df` and `topics` have different number of rows - so they cannot be put together like that. 2 rows are missing. But it would really help if you provided [reproducible example](http://stackoverflow.com/a/5963610/2416535) which means, including a subset of data. – jakub Sep 08 '16 at 07:55
  • I am really sorry, but I really dont know what a reproducible example is I am kindo new here. – ankur gadgilwar Sep 08 '16 at 13:20
  • Click on the link in my comment and you can read all about it :) Or, just provide a subset of your actual data and you are almost there. – jakub Sep 08 '16 at 14:04
  • Hello @jakub The error I guess is because of the difference in the number of rows. Thats happening because the dtm and dtm.new are having different rows. because teh sum of two particular rows is less than 0 and I cant seem to find which ones. – ankur gadgilwar Sep 08 '16 at 16:08
  • And I cant include teh data set as even two rows of the data are too huge for the comment box. :( – ankur gadgilwar Sep 08 '16 at 16:10
  • You can always upload the data somewhere we can download it from. – jakub Sep 08 '16 at 17:30
  • Or a minimal subset like the link describes – Tyler Rinker Sep 09 '16 at 00:26

0 Answers0