Reputation: 21
I'm having trouble exporting a kable table with LaTex using save_kable() function after I add the caption =
argument in kable() function.
I thought it was because I recently updated my R version, RStudio version, TeX version, and everything that could cause errors, but then I switch to R Servers (R 4.3.2 currently), which I never touched upon before. I got the same error message that says "! LaTeX Error: Something's wrong--perhaps a missing \item." If I delete the caption =
, I was able to export the table in LaTex. Here is a minimum example.
library(tidyverse)
library(kableExtra)
library(magick)
dt <- mtcars[1:5, 1:6]
dt %>%
kbl("latex",caption = "Recreating booktabs style table") %>%
save_kable(file = "a.png")
Any help would be appreciated!
Upvotes: 2
Views: 100
Reputation: 6663
I do get the same error when including the caption
argument in kable()
.
There are alternatives to this, that don’t require Latex.
You could use gt::gt()
to create a nice table and then save
it with gtsave()
.
library(gt)
table <-
mtcars[1:5, 1:6] |>
gt() |>
tab_header("Recreating booktabs style table")
table
# Save as png:
gtsave(table, "a.png")
Upvotes: 0