Error in tm_map

I'm trying to read in a csv and then clean it up before I can work with the data. Every line of code after the VectorSouce line (didn't include them all) gives an error, not a warning. I cannot figure out how to fix the code to get it to work. Below are the errors I get. I included a screenshot of the data if that helps, I'm relatively new to coding so any help is greatly appreciated!

Below is the code:
#Load in data
ReviewData <- read_csv("Desktop/deception_data_final.csv")

ReviewCorpus<-Corpus(VectorSource(ReviewData$review))
ReviewCorpus<-tm_map(ReviewCorpus, content_transformer(tolower))
ReviewCorpus<-tm_map(ReviewCorpus, removePunctuation)
ReviewCorpus<-tm_map(ReviewCorpus, removeWords, c(stopwords("english")))

The errors I get:

Error in tm_map.SimpleCorpus(ReviewCorpus, content_transformer(tolower)) :
(converted from warning) transformation drops documents
ReviewCorpus<-tm_map(ReviewCorpus, removeNumbers)
Error in tm_map.SimpleCorpus(ReviewCorpus, removeNumbers) :
(converted from warning) transformation drops documents

Screenshot of the data for reference:
Screen Shot 2022-09-11 at 4.41.42 PM

its an error converted from a warning, so you can adjust your warn options not to do that. 2 treats as error 1 just prints the warning

options(warn=2)
warning("test warning")
options(warn=1)
warning("test warning")

I tried using options(warn=2) and then ran my code and still got the same message. Did I not apply it correctly?

options(warn=2)
ReviewCorpus<-Corpus(VectorSource(ReviewData$review))
ReviewCorpus<-tm_map(ReviewCorpus, content_transformer(tolower))
ReviewCorpus<-tm_map(ReviewCorpus, removeNumbers)
ReviewCorpus<-tm_map(ReviewCorpus, removePunctuation)

ReviewCorpus<-tm_map(ReviewCorpus, content_transformer(tolower))
Error in tm_map.SimpleCorpus(ReviewCorpus, content_transformer(tolower)) :
(converted from warning) transformation drops documents

In your situation warn = 1 would be the choice to make

I tried both, neither would work. I started over with warn=1 but then I saved it, closed R, reopened it and it worked, thank you so much for your help!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.