So as a beginner, I'm trying to do simple text-mining (NLP) using R language.
I preprocessed my data using tm_map
function and inspected it and all the punctuations, numbers were removed.
I also converted the text document in lower case using tolower()
function.
It worked great.
But while creating a document matrix, I'm encountering an issue where the error is:
error in tolower(txt): non character argument
What is this error about and how to go ahead with this?
Is this something related to UTF8?
Any leads would be appreciated.
docs <- tm_map(docs, removePunctuation)
inspect(docs[1])
for(j in seq(docs)) {
docs[[j]] <- gsub("
", " ", docs[[j]])
}
docs <- tm_map(docs, removeNumbers)
docs <- tm_map(docs, content_transformer(tolower))
docs <- tm_map(docs, removeWords, stopwords("english"))
docs <- tm_map(docs, stripWhitespace)
This all worked just fine and my text document (which is simply an ebook) got converted into lower case, with no white spaces, numbers, etc. just fine and the next step returns the error.
# returns the above error.
dtm <- DocumentTermMatrix(docs)
question from:
https://stackoverflow.com/questions/65895168/error-in-tolowertxt-non-character-argument-in-r-for-textmining 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…