R tm package vcorpus: Error in converting corpus to data frame

后端 未结 5 2381
轻奢々
轻奢々 2020-12-01 09:51

I am using the tm package to clean up some data using the following code:

mycorpus <- Corpus(VectorSource(x))
mycorpus <- tm_map(mycorpus,         


        
5条回答
  •  时光取名叫无心
    2020-12-01 10:04

    This is an alternative approach I've used in my own work with text analytics. Essentially, you refer to your document term matrix as a matrix when converting it into a data frame - after which you can run an additional line that makes your variable names R-friendly.

    database <- as.data.frame(as.matrix(mycorpus))

    colnames(database) <- make.names(colnames(database))

    I'm not sure how (or if) this approach differs from the other answers in terms of output but I find this syntax much more straightforward and simpler to implement. Hope this helps!

提交回复
热议问题