【问题标题】:no applicable method for 'tm_map' applied to an object of class "character"没有适用于“字符”类对象的“tm_map”方法
【发布时间】:2018-01-12 20:16:55
【问题描述】:

我的数据如下所示:

1. Good quality, love the taste, the only ramen noodles we buy but they're available at the local Korean grocery store for a bit less so no need to buy on Amazon really.
2. Great flavor and taste. Prompt delivery.We will reorder this and other products from  this manufacturer.
3. Doesn't taste good to me.
4. Most delicious ramen I have ever had. Spicy and tasty. Great price too.
5. I have this on my subscription, my family loves this version. The taste is great by itself or when we add the vegetables and.or meats.
6. The noodle is ok, but I had better ones.
7. some day's this is lunch and or dinner  on second case
8. Really good ramen!

(skip)

我整理这些数据(数字消除、小写转换、特殊字符去除)

我想创建一个矩阵和 sna 图。

但是,数据清理过程存在问题。

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

我该怎么办?

docs<- readLines("C:/Users/xxx/Desktop/3694.txt", encoding = "UTF-8")

library(tm)
docs <- tm_map(docs,removePunctuation)     
docs <- tm_map(docs, tolower)   
docs <- tm_map(docs, PlainTextDocument)
DocsCopy <- docs

【问题讨论】:

  • tm_map 需要应用于语料库对象,而不是字符向量。请参阅包装随附的出色插图:tm Vignette.
  • 尝试docs &lt;- VCorpus(VectorSource(readLines("C:/Users/xxx/Desktop/3694.txt", encoding = "UTF-8"))) 创建您的语料库。
  • 也应该是docs &lt;- tm_map(reuters, content_transformer(tolower))。您是在使用非常古老的 tm 参考吗?

标签: r matrix text-mining tm


【解决方案1】:

干净

x

x

x

x

返回(x) }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2015-08-18
    • 1970-01-01
    相关资源
    最近更新 更多