I am trying to convert an html table created in R via the huxtable
package to a png file using webshot2::webshot
. Unfortunately, the very right side of the output seems to get trimmed off and I can't figure out how to fix this generically.
I don't want to manually tweak the cliprect
parameter because I'll need to do this for many tables and its not scalable if its not generic. However, it is possible to achieve it with this parameter so I wonder why its failing with the other workflow.
Here's an example illustrating the problem:
library(magrittr)
library(huxtable)
set.seed(1337)
data <- matrix(rnorm(25), 35, 10)
my_hux <- as_hux(data) %>%
set_outer_borders(0.4) %>%
map_background_color(by_rows("grey95", "white")) %>%
map_text_color(by_quantiles(c(0.1, 0.9), c("red", "black", "green3")))
quick_html(my_hux, file = "ahuxtable.html", open = FALSE)
webshot2::webshot(url = "ahuxtable.html", file = "ahuxtable.png",
zoom = 5, selector = "table")
I tried this with webshot::webshot
, however the webshot
package seems to be webshot2
's predecessor so I'd prefer a webshot2
solution if there is one.