Converting a Document Term Matrix into a Matrix with lots of data causes overflow

前端 未结 3 1834
孤独总比滥情好
孤独总比滥情好 2020-12-29 09:12

Let\'s do some Text Mining

Here I stand with a document term matrix (from the tm Package)

dtm <- TermDocumentMatrix(
     myCorpus,
          


        
3条回答
  •  轮回少年
    2020-12-29 09:36

    Here is a very very simple solution I discovered recently

    DTM=t(TDM)#taking the transpose of Term-Document Matrix though not necessary but I prefer DTM over TDM
    M=as.big.matrix(x=as.matrix(DTM))#convert the DTM into a bigmemory object using the bigmemory package 
    M=as.matrix(M)#convert the bigmemory object again to a regular matrix
    M=t(M)#take the transpose again to get TDM
    

    Please note that taking transpose of TDM to get DTM is absolutely optional, it's my personal preference to play with matrices this way

    P.S.Could not answer the question 4 years back as I was just a fresh entry in my college

提交回复
热议问题