I'm quite new to R and currently working on a project for my studies (readability vs performance of annual reports). I've literally screened hundreds of posts but could not find a proper solution. So, I'm stuck and need you're help.
My goal is to tm roughly 1000 text documents and export the edited texts from the VCorpus into a folder, including the original file names.
So far I managed to import & do (some) text mining:
### folder of txt files
dest <- ("C:\\Xpdf_pdftotext\\TestCorpus")
### create a Corpus in R
docs <- VCorpus(DirSource(dest))
### do some text mining of the txt-documents
for (j in seq(docs)) {
docs[[j]] <- gsub("\\d", "", docs[[j]])
docs[[j]] <- gsub("\\b[A-z]\\b{3}", "", docs[[j]])
docs[[j]] <- gsub("\\t", "", docs[[j]])
}
Export each file in the Corpus with its original file names. works for 1 file, when assigning a new name:
writeLines(as.character(docs[1]), con="text1.txt")
I've found the command for the meta ID in a post, but I don't know how to include it in my code
docs[[1]]$meta$id
How can I efficiently export the edited textfiles from the VCorpus including their original file names?
Thanks for helping