How do I specify the output file name when using pander's live report generation?

StackOverflow https://stackoverflow.com/questions/23133292

  •  05-07-2023
  •  | 
  •  

Вопрос

I can create a report object, but when I export() it, there is a generic file name containing a random number. I want to be able to specify the file name.

for (report in c("file1", "file2", "file3")) {
 myReport <- Pandoc$new(author="Jerubaal",title="What's my file name?", format="docx")
 myReport$add.paragraph(paste("This is", report))
 myReport$export(open = FALSE)
} 

This gives me files with names such as

  • pander-1c246b334f70.docx
  • pander-1c246b334f70.md

I have tried adding these to Pandoc$new() and also to myReport$export(), but to no avail:

  • output=report
  • file=report
  • filename=report

I will be looping through a lot of things, each of which needs its own report file, so I can't manually rename the files efficiently.

How do I specify the output file name? Thanks!

Это было полезно?

Решение

Use the first or f argument based on the sources. E.g.:

myReport <- Pandoc$new(author="Jerubaal",title="What's my file name?", format="docx")
myReport$add.paragraph("This is it.")
myReport$export('this_is_the_file_name.docx', open = FALSE)

Please feel free to send a pull request or suggestion for an updated documentation.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top