在R中使用tm包创建一个语料库

时间:2016-10-21 03:17:37

标签: r tm corpus

我使用代码

从一些挖掘的推文中创建了一个字符向量
tweets_text <- sapply(tweets, function(x) x$getText(x))

我尝试使用代码

从字符向量源创建语料库
my_corpus <- Corpus(VectorSource(tweets_text)

但我一直收到错误

Error in as. vector(x, "character"):
cannot coerce type 'closure' to vector of type 'character' 

其中一条推文的dput(head(tweets))

的形式返回
structure(function () 
    text, mayCall = character(0), name = "getText", refClassName = "status", superClassMethod = "", class = structure("refMethodDef", package = "methods")))` and str(tweets) is ` $ :Formal class 'refMethodDef' [package "methods"] with 5 slots
  .. ..@ .Data           :function ()  
  .. ..@ mayCall         : chr(0) 
  .. ..@ name            : chr "getText"
  .. ..@ refClassName    : chr "status"
  .. ..@ superClassMethod: chr ""

0 个答案:

没有答案