One way to save the corpus is to first convert into a data frame and then save it as a csv file. Since you didn't provide sample text, i created some reproducible text. Below code first creates corpus from the sample text. Then the stop words are removed. The corpus structure is a list and the text is saved in the content element. The code extracts just the text and creates a data frame. Finally we save the data frame.
Code:
#Reproducible data - Quotes from As You Like It by William Shakespeare
SampleText <- c("All the world's a stage,And all the men and women merely players;They have their exits and their entrances;And one man in his time plays many parts,
His acts being seven ages.",
"Men have died from time to time, and worms have eaten them, but not for love.",
"Love is merely a madness.")
library(tm)
mycorpus <- Corpus(VectorSource(SampleText)) # Corpus creation
mycorpus <-tm_map(mycorpus,removeWords,stopwords("english"))
mycorpus_dataframe <- data.frame(text=unlist(sapply(mycorpus, `[`, "content")),
stringsAsFactors=F)
write.csv(mycorpus_dataframe,'mycorpus_dataframe.csv', row.names=FALSE)
Output:
> print(mycorpus_dataframe , row.names=FALSE)
text
All world's stage,And men women merely players;They exits entrances;And one man time plays many parts,\nHis acts seven ages.
Men died time time, worms eaten , love.
Love merely madness.
>