I've updated r (4.3.0) and Rstudio (RStudio 2023.03.1 Build 446) and when I tried to run knitr with .pdf output (knitr to pdf) on an rmarkdown (.rmd) document I get an unexpected error when rendering. However, when I run the code directly in the console it generates the table normally:
processing file: apuestas.rmd
|...................... | 43% [rmlatitu]
Quitting from lines 1130-1412 [rmlatitu] (apuestas.rmd)
Error in `footnote()`:
! no se pudo encontrar la función "footnote"
Backtrace:
1. ... %>% ...
Ejecución interrumpida
> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.utf8
time zone: Europe/Madrid
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] kableExtra_1.3.4 knitr_1.43 rmarkdown_2.21 scales_1.2.1
[5] gglorenz_0.0.2 ggrepel_0.9.3 fuzzyjoin_0.1.6 lubridate_1.9.2
[9] forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1
[13] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 tidyverse_2.0.0
[17] ggspatial_1.1.8 gridExtra_2.3 ggExtra_0.10.0 ggplot2_3.4.2
[21] rmapshaper_0.5.0 sf_1.0-13
loaded via a namespace (and not attached):
[1] tidyselect_1.2.0 viridisLite_0.4.2 farver_2.1.1
[4] fastmap_1.1.1 promises_1.2.0.1 digest_0.6.31
[7] timechange_0.2.0 mime_0.12 lifecycle_1.0.3
[10] ellipsis_0.3.2 magrittr_2.0.3 compiler_4.3.0
[13] sass_0.4.6 rlang_1.1.1 tools_4.3.0
[16] utf8_1.2.3 yaml_2.3.7 labeling_0.4.2
[19] sp_1.6-0 classInt_0.4-9 curl_5.0.0
[22] xml2_1.3.4 KernSmooth_2.23-21 miniUI_0.1.1.1
[25] withr_2.5.0 grid_4.3.0 fansi_1.0.4
[28] xtable_1.8-4 e1071_1.7-13 colorspace_2.1-0
[31] cli_3.6.1 generics_0.1.3 stringdist_0.9.10
[34] rstudioapi_0.14 httr_1.4.6 tzdb_0.4.0
[37] cachem_1.0.8 DBI_1.1.3 proxy_0.4-27
[40] parallel_4.3.0 rvest_1.0.3 s2_1.1.4
[43] vctrs_0.6.2 V8_4.3.0 webshot_0.5.4
[46] jsonlite_1.8.4 geojsonsf_2.0.3 hms_1.1.3
[49] systemfonts_1.0.4 ineq_0.2-13 jquerylib_0.1.4
[52] units_0.8-2 glue_1.6.2 stringi_1.7.12
[55] gtable_0.3.3 later_1.3.1 munsell_0.5.0
[58] pillar_1.9.0 htmltools_0.5.5 R6_2.5.1
[61] wk_0.7.3 evaluate_0.21 shiny_1.7.4
[64] lattice_0.21-8 highr_0.10 bslib_0.4.2
[67] httpuv_1.6.11 class_7.3-22 Rcpp_1.0.10
[70] svglite_2.1.1 xfun_0.39 pkgconfig_2.0.3
CODE (the complete code as summarized as possible):
---
# title: "title"
# author: "name"
# date: '2023-04-22'
output:
pdf_document:
keep_md: true
keep_tex: true
number_sections: true
fig_caption: yes
fig_width: 10
fig_height: 9
html_document: default
word_document: default
header-includes:
geometry:
- top=2cm
- bottom=1.5cm
- right=1.0cm
- left=1.0cm
graphics: yes
documentclass: article
papersize: a4
lang: es
always_allow_html: yes
editor_options:
chunk_output_type: console
---
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
packages <- c("rmarkdown","knitr","kableExtra")
ipak(packages)
packages <- c("sf","rmapshaper","ggplot2","ggExtra","gridExtra","ggspatial","tidyverse","fuzzyjoin","ggrepel","gglorenz","scales")
ipak(packages)
título <- "título"
formato.tabla <- c("hover", "condensed", "responsive")
tatilocalesapuestas <- dget(file="tablalocales.R")
tatilocalesapuestas %>%
kable(caption=`título`,
row.names=F, digits = 2,
format.args = list(big.mark = ".", decimal.mark = ","),
centering = FALSE,
booktabs = F,
vline="",
linesep = "") %>%
kable_styling(bootstrap_options = formato.tabla,
html_font="\"Trebuchet MS\", verdana, sans-serif",
latex_options = c("striped","scale_down","HOLD_position"),
full_width = F, fixed_thead = F) %>%
row_spec(
0, bold=T, monospace=F, color="white", background="#7B7B7B") %>%
row_spec(
seq(1,nrow(tatilocalesapuestas),2), background="#F9F9F9") %>%
footnote(
general="Elaboración propia",
general_title = "Nota: ",
threeparttable = T
)
DATAFRAME: tablalocales.R
structure(list(`Locales por Titular` = c(1, 2, 3, 4, 5, 6, 7,
8, 9, 11, 12, 13, 14, 15, 18, 28, 39, 54), Titulares = c(21L,
12L, 3L, 2L, 1L, 4L, 3L, 2L, 1L, 3L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L), `% Titulares` = c(34.4262295081967, 19.672131147541,
4.91803278688525, 3.27868852459016, 1.63934426229508, 6.55737704918033,
4.91803278688525, 3.27868852459016, 1.63934426229508, 4.91803278688525,
1.63934426229508, 3.27868852459016, 1.63934426229508, 1.63934426229508,
1.63934426229508, 1.63934426229508, 1.63934426229508, 1.63934426229508
), Locales = c(21, 24, 9, 8, 5, 24, 21, 16, 9, 33, 12, 26, 14,
15, 18, 28, 39, 54), `% Locales` = c(5.58510638297872, 6.38297872340426,
2.3936170212766, 2.12765957446809, 1.32978723404255, 6.38297872340426,
5.58510638297872, 4.25531914893617, 2.3936170212766, 8.77659574468085,
3.19148936170213, 6.91489361702128, 3.72340425531915, 3.98936170212766,
4.78723404255319, 7.4468085106383, 10.3723404255319, 14.3617021276596
), `Acumulado Locales` = c(21, 45, 54, 62, 67, 91, 112, 128,
137, 170, 182, 208, 222, 237, 255, 283, 322, 376), `Acumulado Titulares` = c(21L,
33L, 36L, 38L, 39L, 43L, 46L, 48L, 49L, 52L, 53L, 55L, 56L, 57L,
58L, 59L, 60L, 61L), `Acumulado Locales %` = c(5.58510638297872,
11.968085106383, 14.3617021276596, 16.4893617021277, 17.8191489361702,
24.2021276595745, 29.7872340425532, 34.0425531914894, 36.436170212766,
45.2127659574468, 48.4042553191489, 55.3191489361702, 59.0425531914894,
63.031914893617, 67.8191489361702, 75.2659574468085, 85.6382978723404,
100), `Acumulado Titulares %` = c(34.4262295081967, 54.0983606557377,
59.0163934426229, 62.2950819672131, 63.9344262295082, 70.4918032786885,
75.4098360655738, 78.6885245901639, 80.327868852459, 85.2459016393443,
86.8852459016393, 90.1639344262295, 91.8032786885246, 93.4426229508197,
95.0819672131148, 96.7213114754098, 98.3606557377049, 100)), row.names = c(NA,
-18L), class = "data.frame")
UPDATE: It's a known bug:
Error when loading kableExtra in markdown file after updating to R 4.3.0
There are two options:
- Leave the YAML of the rmarkdown document with a single output.
- Update the kableExtra package in your development version devtools::install_github("kupietz/kableExtra")