R中出现DocumentTermMatrix错误“没有适用于'元'的适用方法应用于类”字符”的对象

时间:2018-08-18 16:29:32

标签: r text-mining corpus

在运行一些代码来清理语料库中的文本元素之后,创建DTM时遇到问题。

# load data
toothbrush <- read.csv("toothbrushtext.csv", stringsAsFactors = FALSE)

# Collapse text columns

toothbrushtext <- unite(toothbrush, Text, Title.Text, Bullet.Points, 
Product.Description, sep = " ")

# Place into corpus
toothbrushcorpus <- VCorpus(VectorSource(toothbrushtext$Text))

# Run various cleaning steps (only show some here)

toothbrushcorpusclean <- tm_map(toothbrushcorpus, tolower)

toothbrushcorpusclean <- tm_map(toothbrushcorpusclean, removeWords, 
stopwords())

toothbrushcorpusclean <- tm_map(toothbrushcorpusclean, stemDocument)

# Create a Document term Matrix
toothbrushdtm <- DocumentTermMatrix(toothbrushcorpusclean)

# Error: Error in UseMethod("meta", x) : 
no applicable method for 'meta' applied to an object of class "character"

知道是什么原因造成的吗?

感谢您的帮助!

0 个答案:

没有答案