I've looked at the other similar questions that have been posted here (like this), but the problem persists.
I have a dataframe of textual data, which I need to stem. So I'm converting it into a corpus, stemming it, then completing the words from the stems, and then trying to get a dataframe of text as output.
myCorpus <- Corpus(VectorSource(textDf$text))
myCorpus <- tm_map(myCorpus, removeWords, stopwords('english'))
myCorpus <- tm_map(myCorpus, content_transformer(tolower))
myCorpus <- tm_map(myCorpus, removePunctuation)
dictCorpus <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=dictCorpus)
Now I'm trying to get a dataframe back from this corpus so I've tried these following commands.
dataframe<-data.frame(text=unlist(sapply(myCorpus, '[', "content")),
stringsAsFactors=F)
and
dataframe<-data.frame(text=unlist(sapply(myCorpus,
[)), stringsAsFactors=F)
and also
dataframe <-
data.frame(id=sapply(corpus, meta, "id"),
text=unlist(lapply(sapply(corpus, '[', "content"),paste,collapse="\n")),
stringsAsFactors=FALSE)
from this link
All of them produce the following error:
Error in UseMethod("meta", x) :
no applicable method for 'meta' applied to an object of class "character"
Any help would be greatly appreciated.