I am trying to run some code, hoping that it will allow me to use kableExtra when knitting to docx:
library(kableExtra)
kable(mtcars, "latex", booktabs = T) %>%
kable_styling(latex_options = c("striped", "scale_down")) %>%
row_spec(1, color = "red") %>%
as_image()
(The code is borrowed here: https://haozhu233.github.io/kableExtra/save_kable_and_as_image.html)
Prior to running the code above, I install ghostscript and these packages (as instructed):
install.packages("magick")
install.packages("webshot")
webshot::install_phantomjs()
When I press knit, I recieve this message:
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020/W32TeX) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
Error in save_kable_latex(x, file, latex_header_includes, keep_tex) : We hit an error when trying to
use magick to read the generated PDF file. You may check your magick installation and try to use
magick::image_read to read the PDF file manually. It's also possible that you didn't have ghostscript
installed.
So, I try to use magick::image_read to read the PDF file manually, Which only results in "R Session Aborted" (the similar function in magick: magick::image_read_pdf works just fine).
How do I solve this?