R tm package create matrix of Nmost frequent terms

蹲街弑〆低调 提交于 2019-12-03 13:43:43
Pop

The term-document matrices in tm are already created as sparse matrices. Here, mydata.tdm$i and mydata.tdm$j are the vectors of indexes of the matrix and mydata.tdm$v is the related vector of frequencies. So that you can create a sparse matrix writing :

sparseMatrix(i=mydata.tdm$i, j=mydata.tdm$j, x=mydata.tdm$v)

Then you can use rowSums and link the rows, you're interested in, to the terms, they stand for, with $Terms.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!