首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将huxtable保存为R中的png文件

如何将huxtable保存为R中的png文件
EN

Stack Overflow用户
提问于 2022-06-10 12:22:09
回答 2查看 124关注 0票数 1

huxtable包附带quick_*函数来保存输出,如html (通过quick_html)、pdf (通过quick_pdf)等。

然而,似乎没有办法直接存钱(如巴布亚新几内亚)。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-10 12:22:09

不久前,我就有了这个问题,自己解决了,但我认为它可能对遇到类似挑战的其他人有帮助。

幸运的是,包webshot允许截图使用quick_html保存的huxtable输出。

以下是解决办法:

代码语言:javascript
复制
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

票数 0
EN

Stack Overflow用户

发布于 2022-06-10 12:34:55

帕特里克的回答不错。或者,您可以使用GhostScript将pdf转换为png。

代码语言:javascript
复制
gs -sDevice=png16m -sOutputFile="hux.png" hux.pdf
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72574242

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档