在运行一些代码来清理语料库中的文本元素之后,创建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"
知道是什么原因造成的吗?
感谢您的帮助!