I'm attempting to use removeWords in the R tm package using the following code:
docs <- tm_map(docs, removeWords, stopwords("english"))
and I get the following error message:
Error in sort (words, decreasing = TRUE) :
argument "words" is missing, with no default
All of the other transformations I've attempted on my corpus have worked as intended (tolower, removeNumbers, stripWhitespace, removePunctuation etc...) but I can not get removeWords to work properly, and can not find anything online about this particular error message.
I'd very much appreciate any insight into what might be causing this error.
Edit: My corpus consists of html documents all located in the same folder. The code I'm using to test the removeWords transformation is as follows:
setwd(“C:/folder”)
library(RCurl)
library(XML)
library (tm)
library (SnowballC)
docs <- Corpus(DirSource(“C:/folder”))
docs <- tm_map(docs, removePunctuation)
docs <- tm_map(docs, tolower)
docs <- tm_map(docs, removeNumbers)
docs <- tm_map(docs, removeWords, stopwords(“english”))
data(crude); tm_map(crude, removeWords, stopwords("english")). You should provide some sort of reproducible example to make it clear how your situation is different. What you have provided should work. Perhaps provide the version information fromsessionInfo(). - MrFlicktolower. Trydocs <- tm_map(docs , content_transformer(tolower)). Also I assumeremovePucntuationis just a typo? - MrFlicktraceback()and verify the value ofclass(docs)before runningremoveWords. Also i assume you are usingtm_mapand nottm_mapshas you've typed. It's important that the code you share accurately reflects what you are actually running -- that's the whole point! - MrFlick