I'm working on a convenience function in R that prints a publication quality LaTeX table from some common model objects. It all works just great for me on my Mac, but I've built it largely for a colleague who's on a PC, for whom the file writing fails when calling save_kable() from the kableExtra package.
We get no output whatsoever from this. No pdf and no error messages.
A simple reproducible example, which fails in the same way, is as follows:
library(knitr)
library(here)
library(kableExtra)
outfile = here("test_table.png")
table = head(iris)
latex = kable(x = table, format = "html")
save_kable(x = latex, file = outfile)
When using as_image(), we get the following "cannot find file" error:
Error in include_graphics(temp_png, dpi = img_dpi) : Cannot find the file(s): "C:/R Projects/export-anova/test.pdf"
which has been talked about before in the context of blogdown. But that's not our context.
Other potentially relevant tidbits:
- We can save table images with
format = 'html', but they are not formatted properly. We wantbooktabs. - If we use the above to output LaTeX code, rather than a file, then Knit with RMarkdown, we do get the correct output, but it's a full page document that needs to be cropped.
- Same results with extensions .pdf, .png, and .jpeg
Running Windows 10, R version 4.1.2, and kableExtra version 1.3.4. The LaTeX settings in RStudio are below.
Any ideas? Seems like we're so close!
