Pass df_print an arbitrary function when knitting in RStudio

When using rmarkdown

to insert a document in RStudio, I want to use a specific function to print data.frame

(in my case pander

to get a multi-line table). The package documentation rmarkdown

says that in addition to the four valid methods that can be passed to df_print

, I can also pass an arbitrary function to it:

In addition to the above methods, you can also pass an arbitrary function that will be used to print data frames.

I want to set a parameter df_print

to a YAML header:

output:
  pdf_document:
    df_print: pander

      

However, when using the Knit button in RStudio, these are errors saying:

Error: Invalid value for df_print (valid values are default, kable, tibble, paged
Execution halted

      

But, when I call the function render

directly:

render("example.Rmd", pdf_document(df_print = pander))

      

The document displays just fine and I get the PDF file I want. Is RStudio built in to the knitting process when I use the Knit button in such a way that it doesn't happen when I just call render

directly? Why can't I pass an arbitrary function in the YAML header?

I also tried skipping pander::pander

but it didn't help.

+3


source to share





All Articles