It seems that I am having trouble using kableExtra
when trying to create a PDF by rendering an Rmd-file from an R Script. I have had no success in trying to follow the instructions at:
R markdown compile error: https://github.com/rstudio/bookdown/issues/440 https://community.rstudio.com/t/rendering-both-pdf-and-html-is-only-possible-interactively-not-via-script/19520/3 https://github.com/haozhu233/kableExtra/issues/301
I'll access the packages from the script:
library(tidyverse)
library(knitr)
library(rmarkdown)
library(tinytex)
Make the Rmd-file:
---
output: pdf_document
---
{r, comment = NA, echo = FALSE, message = FALSE, warning = FALSE}
tibble(x = 1, y = 2, z = 3) %>%
kable()
Render the Rmd-file from the script using:
render('C:/Users/Rasmus/SO/Test.Rmd',
output_file = "Test.pdf",
output_format = 'pdf_document',
output_dir = 'C:/Users/Rasmus/SO')
This gives me a PDF with a table. But if I start out by running library(kableExtra)
alongside the others, and then apply the rendering procedure, I get a PDF with:
x
y
z
1
2
3
After running library(kableExtra)
, I have tried the rendering procedure on the following Rmd-file:
---
output: pdf_document
---
{r, comment = NA, echo = FALSE, message = FALSE, warning = FALSE}
tibble(x = 1, y = 2, z = 3) %>%
kable() %>%
kable_styling(latex_options = 'scale_down')
This returns:
output file: Test.knit.md
Error: Functions that produce HTML output found in document targeting latex output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: true
Note however that the HTML output will not be visible in non-HTML formats.
What is stopping me from using kableExtra
?