UseMethod中的错误(" meta",x):没有适用于' meta'的方法适用于类"字符"的对象

时间:2015-07-21 18:38:00

标签: r macos

我有以下数据:

text <- c("@_rpg_17 little league travel tourney. These parents about to be wild.", 
"@auscricketfan @davidwarner31 yes WI tour is coming soon", "@keralatourism #favourite #destination #munnar #topstation https://t.co/sm9qz7Z9aR", 
"@NWAWhatsup tour of duty in NWA considered a dismal assignment?  Companies send in their best ppl and then those ppl don't want to leave", 
"Are you Looking for a trip to Kerala? #Kerala-prime tourist attractions of India.Visit:http://t.co/zFCoaoqCMP http://t.co/zaGNd0aOBy", 
"Are you Looking for a trip to Kerala? #Kerala, God's own country, is one of the prime tourist attractions of... http://t.co/FLZrEo7NpO")

以下是代码:

library(tm)
myCorpus <- Corpus(VectorSource(text))
myCorpus <- tm_map(myCorpus, tolower)
myCorpus <- tm_map(myCorpus, removePunctuation)
myCorpus <- tm_map(myCorpus, removeNumbers)
removeURL <- function(x) gsub("http[[:alnum:]]*", "", x)
myCorpus <- tm_map(myCorpus, removeURL)
myStopwords <- c(stopwords('english'), "available", "via")
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)
myCorpusCopy <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)
myTdm <- TermDocumentMatrix(myCorpus, control=list(wordLengths=c(3,Inf)))

这曾经在我的Windows机器中完美地工作。不确定这是否是因为我目前使用的mac。我在主题行中得到了上面给出的错误。在其他情况下,我得到其他错误:

Error in UseMethod("meta", x) : no applicable method for 'meta' applied to an object of class "character"
In addition: Warning message:In mclapply(unname(content(x)), termFreq, control) :all scheduled cores encountered errors in user code

我使用R版本3.2.0(2015-04-16) - &#34; Full of Ingredients&#34;,R-Studio版本0.98.1103,Mac OS X Yosemite 10.10.3,库(tm)版本0.6 - 1.我在代码中尝试了以下更改:

  1. 添加了content_transformation(工具栏)
  2. 在每个可执行行的代码末尾添加了lazy = TRUE
  3. 删除了代码:myCorpus&lt; - tm_map(myCorpus,stemDocument)
  4. 在(tolower)
  5. 之后添加了mc.cores = 1
  6. 在代码的每一行中添加了mc.cores = 1
  7. 将最后一个代码更改为myTdm&lt; - TermDocumentMatrix(Corpus(VectorSource(myCorpus)))
  8. 在myCorpus&lt; - tm_map(myCorpus,tolower)使用myCorpus&lt; - tm_map(myCorpus,PlainTextDocument)之后,立即尝试使用content_transformation。
  9. 和堆栈溢出中给出的其他解决方案。似乎没什么用。不知道如何解决?

0 个答案:

没有答案