21.6 Word Documents
A simple open source tool to convert Microsoft Word documents into
antiword. The separate
needs to be installed, but once it is available it is used by
to convert Word documents into text for loading into R.
To load a corpus of Word documents we use the tm::readDOC() reader function:
<- Corpus(DirSource(cname), readerControl=list(reader=readDOC))docs
Once we have loaded our corpus the remainder of the processing of the corpus within R is then as follows.
antiword program takes some useful command line
arguments. We can pass these through to the program from
tm::readDOC() by specifying them as the character string
<- Corpus(DirSource(cname), readerControl=list(reader=readDOC("-r -s")))docs
-r requests that removed text be included in the
-s requests that text hidden by Word be included.
Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.