huxtable包附带quick_*函数来保存输出,如html (通过quick_html)、pdf (通过quick_pdf)等。
然而,似乎没有办法直接存钱(如巴布亚新几内亚)。
发布于 2022-06-10 12:22:09
不久前,我就有了这个问题,自己解决了,但我认为它可能对遇到类似挑战的其他人有帮助。
幸运的是,包webshot允许截图使用quick_html保存的huxtable输出。
以下是解决办法:
library(magrittr)
library(huxtable)
set.seed(1337)
data <- matrix(rnorm(25), 5, 5)
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)
# higher zoom increases resolution and image size
# you may need to run "webshot::install_phantomjs()" for this to work
webshot::webshot(url = "ahuxtable.html", file = "ahuxtable.png",
zoom = 5, selector = "table")flextable似乎也有一个类似的问题,它已经解决了here。
发布于 2022-06-10 12:34:55
帕特里克的回答不错。或者,您可以使用GhostScript将pdf转换为png。
gs -sDevice=png16m -sOutputFile="hux.png" hux.pdfhttps://stackoverflow.com/questions/72574242
复制相似问题