webshot does not save Viewer (table1)

时光总嘲笑我的痴心妄想 提交于 2021-01-29 09:24:56

问题


I am trying to save as an image an html table produced via the package table1 (class: "table1" "html" "character")

The image is displayed in the Viewer (RStudio) but cannot be saved in any way.

I tried, with reference to the example below:

library(plotly)
library(htmlwidgets)
library(webshot)

saveWidget(t, "temp.html")
webshot("temp.html", "temp.png")

example from https://www.rdocumentation.org/packages/table1/versions/1.2

require(table1)
require(survival)

dat <- subset(survival::pbc, !is.na(trt))  # Exclude subjects not randomized

dat$trt     <- factor(dat$trt, levels=1:2, labels=c("D-penicillamine", "Placebo"))
dat$sex     <- factor(dat$sex, levels=c("m", "f"), labels=c("Male", "Female"))
dat$stage   <- factor(dat$stage, levels=1:4, labels=paste("Stage", 1:4))
dat$edema   <- factor(dat$edema, levels=c(0, 0.5, 1),
                      labels=c("No edema",
                               "Untreated or successfully treated",
                               "Edema despite diuretic therapy"))
dat$spiders <- as.logical(dat$spiders)
dat$hepato  <- as.logical(dat$hepato)
dat$ascites <- as.logical(dat$ascites)

table1(~ age + sex + stage + edema + spiders + hepato + ascites +
         platelet + protime + albumin + alk.phos + ast + bili + chol +
         copper + trig | trt, data=dat)

来源:https://stackoverflow.com/questions/61715760/webshot-does-not-save-viewer-table1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!