I have been trying to work with RMarkdown more and use it for communication with my team (who are not R users), and to that end, I've been trying to do reports out to PDF. I've been creating tables with kable()
, but found that additional formatting is necessary, so I've been trying to work with kableExtra
, but find that it hangs on the rendering of the PDF.
Below is my simplified RMarkdown file. Although I want to use kable_styling()
, I have it commented out here, and what is bothering me is that the PDF will or won't render solely based on whether library(kableExtra)
is included or not. I'm not even using the kableExtra
functions -- just calling the library causes failure to render.
(Note: Below I have removed the closing "```" from the code chunks in order to show the file as close as possible.)
---
title: "Troubleshooting RMarkdown to PDF"
author: "Scott Jackson <br/> Frustrated RMarkdown Learner"
date: "`r format(Sys.Date(), '%B %d, %Y')`"
output: pdf_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
library(knitr)
library(kableExtra) # If you comment out this line, the PDF will render; as-is though, it never completes the render.
library(tidyverse)
knitr::opts_chunk$set(echo = FALSE)
options(knitr.table.format = "latex")
## A Simple Test
Running this next chuck works when run interactively, but not when knit to a PDF.
```{r test}
mtcars[1:5, 1:4] %>%
kable(col.names =c("MPG", "# Cyl", "Displacement", "Horsepower"),
caption = "mtcars example") #%>%
# kable_styling(font_size = 12)
> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=C LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] kableExtra_1.3.4.9000 MondelezR_0.1.0.9001 janitor_2.2.0 lubridate_1.9.3 forcats_1.0.0
[6] stringr_1.5.0 dplyr_1.1.3 purrr_1.0.2 readr_2.1.4 tidyr_1.3.0
[11] tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0 knitr_1.45
loaded via a namespace (and not attached):
[1] sass_0.4.7 utf8_1.2.4 generics_0.1.3 xml2_1.3.5 stringi_1.7.12 hms_1.1.3 digest_0.6.33
[8] magrittr_2.0.3 evaluate_0.23 grid_4.3.2 timechange_0.2.0 fastmap_1.1.1 jsonlite_1.8.7 httr_1.4.7
[15] rvest_1.0.3 fansi_1.0.5 viridisLite_0.4.2 scales_1.2.1 jquerylib_0.1.4 cli_3.6.1 rlang_1.1.2
[22] munsell_0.5.0 cachem_1.0.8 withr_2.5.2 yaml_2.3.7 tools_4.3.2 tzdb_0.4.0 colorspace_2.1-0
[29] webshot_0.5.5 vctrs_0.6.4 R6_2.5.1 lifecycle_1.0.4 snakecase_0.11.1 pkgconfig_2.0.3 bslib_0.5.1
[36] pillar_1.9.0 gtable_0.3.4 glue_1.6.2 systemfonts_1.0.5 highr_0.10 xfun_0.41 tidyselect_1.2.0
[43] rstudioapi_0.15.0 htmltools_0.5.7 rmarkdown_2.25 svglite_2.1.2 compiler_4.3.2
Why does this happen? I have this test file stripped to the simplest version of itself.