An update: Running this block of code: # Load libraries library(tcltk) library(tidyverse) library(officer)
filepath <- setwd(tk_choose.dir()) filename <- "Now they want us to charge our electric cars from litter bins.docx" #full_filename <- paste0(filepath, filename) full_filename <- paste(filepath, filename, sep="/") if (!file.exists(full_filename)) { message("File missing") } else { content <- read_docx(full_filename) |> docx_summary() # this reads docx for the full filename and # passes it ( |> command) to the next line # which summarises it. # the result is saved in a data frame object # called content which we shall show some # heading into from head(content) } Results in this error now:Error in x$doc_obj : $ operator is invalid for atomic vectors Thank you. On 30/12/2023 12:12, Andy wrote: > Hi Eric > > Thanks for that. That seems to fix one problem (the lack of a > separator), but introduces a new one when I complete the function > Calum proposed:Error in docx_summary() : argument "x" is missing, with > no default > > The whole code so far looks like this: > > > # Load libraries > library(tcltk) > library(tidyverse) > library(officer) > > filepath <- setwd(tk_choose.dir()) > > filename <- "Now they want us to charge our electric cars from litter > bins.docx" > #full_filename <- paste0(filepath, filename) # Calum's original suggestion > > full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix > > #lets double check the file does exist! # The rest here is Calum's > suggestion > if (!file.exists(full_filename)) { > message("File missing") > } else { > content <- read_docx(full_filename) > docx_summary() > # this reads docx for the full filename and > # passes it ( |> command) to the next line > # which summarises it. > # the result is saved in a data frame object > # called content which we shall show some > # heading into from > > head(content) > } > > > Running this, results in the error cited above. > > Thanks as always :-) > > > > > On 30/12/2023 11:58, Eric Berger wrote: >> full_filename <- paste(filepath, filename,sep="/") > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.