没有将适用于"tm_map"的适用方法应用于类"character"的对象. [英] no applicable method for 'tm_map' applied to an object of class "character"

查看:315
本文介绍了没有将适用于"tm_map"的适用方法应用于类"character"的对象.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据如下:

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)

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

I organize this data (number elimination, lowercase conversion, removal of special characters)

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

I want to create a matrix and sna graph.

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

However, there is a problem with the data cleanup process.

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

推荐答案

清洁<-函数(x){

clean <- function(x){

x< -tolower(x)

x <-tolower(x)

x< -removeWords(x,停用词('en'))

x <-removeWords(x,stopwords('en'))

x< -removePunctuation(x)

x <-removePunctuation(x)

x< -stripWhitespace(x)

x <-stripWhitespace(x)

返回(x) }

这篇关于没有将适用于"tm_map"的适用方法应用于类"character"的对象.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆