I have looked through all of the questions on Stack Overflow regarding why removeWords isn't working and for me, it is none of the reasons already posted.
Here's what I have:
setwd("not shown")
filenames<-list.files(getwd(),pattern="*.txt")
files<-lapply(filenames,readLines)
docs<-Corpus(VectorSource(files))
writeLines(as.character(docs[[1]]))
docs <- tm_map(docs, removePunctuation)
docs <- tm_map(docs, removeNumbers)
docs<-tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, stripWhitespace)
docs <- tm_map(docs, removeWords, c(stopwords("english"))
Everything works and runs fine until the last line for the removeWords.
Here's the error I get:
Error in gsub(sprintf("(*UCP)\b(%s)\b", paste(words, collapse = "|")), : input string 1 is invalid UTF-8
Any thoughts on why I am receiving this error?