Not applicable method for 'tm_map' applied to object of class "character"

My data looks like this:

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 this is lunch and or dinner  on second case
8. Really good ramen!

(skip)

      

I organize this data (remove number, convert to lower case, remove special characters)

I want to create a sna matrix and graph.

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

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

      

What should I do?

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

      

+4


source to share


1 answer


pure <- function (x) {

x <-tolower (x)

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



x <-removePunctuation (x)

x <-stripWhitespace (x)

return (x)}

-1


source







All Articles