[R] Help request: Parsing docx files for key words and appending to a spreadsheet

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Dec 29 21:59:00 CET 2023

В Fri, 29 Dec 2023 20:17:41 +0000
Andy <phaedrusv using gmail.com> пишет:

> doc_in <- read_docx(files)
> Results in this error:Error in filetype %in% c("docx") && 
> grepl("^([fh]ttp)", file) :'length = 9' in coercion to 'logical(1)'

help(read_docx) says that the function only imports one docx file. In
order to read multiple files, use a for loop or the lapply function.

> content <- officer::docx_summary("Now they want us to charge our 
> electric cars from litter bins.docx") # A title of one of the articles
> The error returned is:Error in x$doc_obj : $ operator is invalid for 
> atomic vectors

A similar problem here. help(docx_summary) says that the function
accepts "rdocx" objects returned by read_docx, not file paths. A string
in R is indeed an atomic vector of type character, length 1.

docx_summary(read_docx("Now they want us to charge our electric cars
from litter bins.docx")) should work.

Best regards,

More information about the R-help mailing list