Is rmarkdown::render the same as clicking Knit? Apparently not.

Essentially my question is "What's the difference between clicking Knit from within RStudio and using the rmarkdown::render function? Or perhaps it should be: what command in a script is the same as clicking Knit in rStudio? I thought it was rmarkdown::render, but that's where I ran into trouble.

I can knit a particular .rmd file but get an error using the render function. Apologies for not being able to provide the code in the .rmd but it's sensitive. Here's the code from the r script.

rmarkdown::render("Example.rmd",
                  output_format = "pdf_document",
                  output_file = "Example.pdf")  

It produces:

! LaTeX Error: Unknown float option `H'.
Error: LaTeX failed to compile . See https://yihui.org/tinytex/r/#debugging for
debugging tips. See rebalReport_ok2delete.log for more info.
(By the way the link to the debugging tips isn't working. )

Yet clicking the Knit button with Example.rmd works fine.
Thanks.

Clicking the Knit button will call rmarkdown::render in a background R session.

This means it should be the same if you render in a clean session.

Have you looked inside rebalReport_ok2delete.log ? Is there more information ?

Which latex distribution do you have installed to convert to PDF ?

I can't explain the difference leading to this error for now. Having more information would help.

Upgrading your packages in R (rmarkdown, tinytex, knir) and LaTeX could help.

Updated knitr to 1.31 from 1.3. tinytex and rmarkdown were already up to date. That worked. Under global options, 'use tinytex when compiling .tex files' is not checked? Should it be?

It is not required that this is checked. It is useful is you use RStudio IDE to compile .tex file directly and want to benefit from tinytex feature like auto installing of missing package.

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.