I'm getting the following error when attempting to dynamically generate r markdown reports via a for loop, and compressing it into a single zip file to be downloaded.
Here's a snippet of my code:
output$downloadData <- downloadHandler(
filename = function() {
paste0("output", ".zip")
},
content = function(file) {
myData <- someVector
fs <- c()
withProgress(message = "Generating Report", detail = "This may take awhile...", value = 0, {
for (i in myData) {
path <- paste0(i, ".docx")
params <- list(a = something, b = something, c = something) # some params
rmarkdown::render("test.rmd", rmarkdown::word_document(),
params = params, output_file = path)
fs <- c(fs, path)
incProgress(1/5)
Sys.sleep(0.1)
}
zip(file, fs)
})
},
contentType = "application/zip"
)
and here's the error that I am getting:
Warning in if (!file_test("-d", dirname(name))) dir.create(dirname(name), :
the condition has length > 1 and only the first element will be used
Quitting from lines 30-46 (test.rmd)
Warning: Error in dir.create: invalid 'path' argument
[No stack trace available]
Tried to uncomment the entire chunk I have in my test.rmd file, but then I get the following error:
Warning in if (nzchar(file_ext)) paste(".", file_ext, sep = "") else "" :
the condition has length > 1 and only the first element will be used
pandoc: pandocd4b2c86ff4f.docx: openBinaryFile: does not exist (No such file or directory)
Warning: Error in : pandoc document conversion failed with error 1
[No stack trace available]
Not sure what's the issue with this, appreciate any help here!