I am trying to save a kableExtra html table to .png format in R. This worked smoothly for previous versions of R, but I recently started getting an error message I cannot understand after switching to version 4.3.2. There are no regular expressions in the contents of the table so I am not sure what to make of this.
I have tried uninstalling and reinstalling kableExtra and webshot2, to no avail.
Here is an example:
library(kableExtra)
df <- data.frame(x = c(1:10), y = c(11:20))
tab <- kbl(df) |> kable_classic()
save_kable(tab, "tab.png")
This should save a .png image of the table, but instead I get the following error message:
Warning: TRE pattern compilation error 'Invalid back reference'Error in sub(file, "", filename) : invalid regular expression 'C:\Users\ECS155\AppData\Local\Temp\2\Rtmp0SBfQp\tab34a035bd7a3f.html', reason 'Invalid back reference'
*with full traceback: *
Error in sub(file, "", filename) : invalid regular expression 'C:\Users\ECS155\AppData\Local\Temp\2\Rtmp0SBfQp\tab34a035bd7a3f.html', reason 'Invalid back reference'
7. sub(file, "", filename)
6. file_url(x)
5. FUN(X[[i]], ...)
4. vapply(url, function(x) { if (!is_url(x)) { file_url(x) } ...
3. webshot2::webshot(file_temp_html, file, ...)
2. save_kable_html(x, file, bs_theme, self_contained, extra_dependencies, density, ...)
1. save_kable(tab, "tab.png")
Thanks in advance for your help!
I had to delete and reinstall htmltools
.