创建 TDM 时出错 - “没有适用于'元'的适用于类”字符“对象的方法”

Error while creating the TDM - "No applicable method for 'meta' applied to an object of class "character""

提问人:yem 提问时间:10/20/2023 最后编辑:nageenyem 更新时间:10/20/2023 访问量:13

问:

在创建 tm 包 TermDocumentMatrix 时,我收到错误。我使用了以下代码。

int_vc <- VCorpus(int_vc)

int_vc <- tm_map(int_vc, tolower)
int_vc <- tm_map(int_vc, removePunctuation)
int_vc <- tm_map(int_vc, removeNumbers)
inv_vc <- tm_map(int_vc, removeWords, stopwords("english"))
int_vc <- tm_map(int_vc, stripWhitespace)

inv_tdm <- TermDocumentMatrix(int_vc)

没有应用于类对象的“meta”的适用方法中的错误UseMethod("meta", x):character

文本挖掘 TM

评论


答:

0赞 yem 10/20/2023 #1

这是由于内容转换导致的错误:

我之前的代码:

int_vc <- tm_map(int_vc, tolower)

我已更改为:

int_vc <- tm_map(int_vc, content_transformer(tolower))

现在这段代码工作正常。