R中的tm包的文档术语矩阵 [英] Document-Term-Matrix of tm Package in R

查看:176
本文介绍了R中的tm包的文档术语矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中使用tm包的文档术语矩阵.我遇到一个错误:

I am using document term matrix of tm package in R. I faced an error saying:

Doc <- DocumentTermMatrix(Data)
Error in UseMethod("TermDocumentMatrix", x) : 

no applicable method for 'TermDocumentMatrix' applied to an object of class "table"

我尝试了数据框,数据表,矩阵和表,但是我一次又一次地遇到错误.您能告诉我该怎么办吗?

I tried data frame, data table, matrix and table but I faced the error again and again. Could you please tell me what should I do?

推荐答案

您错过了一个步骤...您必须首先创建一个语料库" ...

You missed a step... you have to create a "corpus" first...

library("tm")
txt <- c("some text", "here in this", "vector as an example")
corpus <- Corpus(VectorSource(txt))
tdm <- TermDocumentMatrix(corpus)

这篇关于R中的tm包的文档术语矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆