问题
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