4

I have successfully used save_kable() from kableExtra to export latex tables into *.png before. However, after updating R to the version 4.0.2, save_kable always ends with R fatal error (no specific error message is shown, the session is just aborted). I installed a clean version o R 3.6.3 and everything works fine again.

Next, I re-installed MikTEX, but this does not seem to be the problem because R Markdown can knit a .pdf file without an issue (in the 4.0.2 version). Also, using save_kable with "html" options works fine and exports the table into .png. The problem seems to be specific for latex.

Looking at sessionInfo(), the only difference is that R 3.6.3 automatically loads the 'magick' package, while R 4.0.2 does not. However, loading the magick package manually in the latter R version does not solve the problem. Then, of course, the sessions differ in the "compiler" package versions. Maybe this is the source of the problem?

Any help would be much appreciated. The problem can be reproduced with minimal code such as

kable(mtcars, "latex") %>%  save_kable("test.png")

Here is the sessionInfo

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] magick_2.4.0     kableExtra_1.1.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        rstudioapi_0.11   knitr_1.29        xml2_1.3.2        magrittr_1.5     
 [6] hms_0.5.3         rvest_0.3.5       munsell_0.5.0     viridisLite_0.3.0 colorspace_1.4-1 
[11] R6_2.4.1          rlang_0.4.7       stringr_1.4.0     httr_1.4.1        tools_4.0.2      
[16] webshot_0.5.2     xfun_0.15         htmltools_0.5.0   ellipsis_0.3.1    digest_0.6.25    
[21] tibble_3.0.3      lifecycle_0.2.0   crayon_1.3.4      readr_1.3.1       vctrs_0.3.2      
[26] glue_1.4.1        evaluate_0.14     rmarkdown_2.3     stringi_1.4.6     compiler_4.0.2   
[31] pillar_1.4.6      scales_1.1.1      pkgconfig_2.0.3  
joe.s
  • 41
  • 2
  • This is almost certainly best answered by emailing the maintainer of the `kableExtra` package directly. Also, are your packages `kableExtra` and `webshot` up to date, i.e. R4.x compatible? – Carl Witthoft Jul 20 '20 at 18:08
  • Thanks, I hoped that if this is a general problem, more people would find it useful to see the solution. However, I may email the author and post the answer here. Both `kableExtra` and `webshot` are R (≥ 3.1.0) and I installed their most up-to-date versions. – joe.s Jul 21 '20 at 04:33

1 Answers1

0

This seems to be a windows specific problem. I actually just asked a recent question here kableExtra HTML styling in Rmarkdown and kable_save() Some of the things I have seen mentioned as potential fixes are listed there such as updating ghostscript, not using tinytext, updating some latex packages including 'standalone', and editing the policy.xls document in ImageMagick ImageMagick security policy 'PDF' blocking conversion.

None of these worked for me and I get the same crashing issues the second I try to kable_save a latex format into png. However, some other Windows users have found success with the steps above so maybe try that out and see how it goes.

Cadbery
  • 31
  • 2