0

first i run this line executed successfully corpus table size is 2.39.4 MB

tdm <- TermDocumentMatrix(corpus)

but facing error when run the following line

m <- as.matrix(tdm)

error is showing as follows
Error: cannot allocate vector of size 15.9 Gb

image is attached

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • Your `TermDocumentMatrix` is probably a sparse matrix. Doing `as.matrix()` forces it to expand to full size. Sounds like you just don't have enough RAM to hold the full size matrix. Why are you trying to do `as.matrix`? – MrFlick Jul 17 '18 at 20:25
  • FYI, I [edited your code](https://stackoverflow.com/editing-help) (to `code`-ify your code/error) and removed the `rstudio*` tags, as this is about neither the desktop IDE (`[rstudio]`) nor the web-based IDE (`[rstudio-server]`). – r2evans Jul 17 '18 at 20:28
  • 1
    maybe relevant: https://stackoverflow.com/questions/50890935/why-does-as-matrix-result-in-memory-overload-while-running-text-mining-in-r re comments using the `slam` library – user20650 Jul 17 '18 at 20:35
  • @MrFlick SIR i am trying this code to draw wordcloud tdm <- TermDocumentMatrix(tweetshash) m <- as.matrix(tdm1) v <- sort(rowSums(m),decreasing=TRUE) d <- data.frame(word = names(v),freq=v) pal <- brewer.pal(9, "BuGn") pal <- pal[-(1:2)] png("wordcloud.png", width=1280,height=800) wordcloud(d$word,d$freq, scale=c(8,.3),min.freq=2,max.words=100, random.order=T, rot.per=.15, colors=pal, vfont=c("sans serif","plain")) – M Waqas Asif Jul 17 '18 at 21:47
  • @MrFlick sir i have a csv file contain more than 58900 tweets i want to draw word clod and Word Association Graph This cluster graph is useful for visualizing associations among the most frequent terms in a corpus of Tweets, and if # and @ symbols are retained after cleaning a corpus, then it provides a visual for how the top terms in a corpus are associated with the top hashtags and username mentions. sir actually abouve graph i want to draw please please help me – M Waqas Asif Jul 17 '18 at 21:57

0 Answers0