❝本节来介绍如何使用「bstfun」包的函数来自定义绘制各种图表,此款R包包含众多函数都非常的实用,下面小编来简单介绍几个案例来做展示,希望各位观众老爷能够喜欢,更多详细文档请参考作者官方文档。 ❞
❝https://rdrr.io/github/ddsjoberg/bstfun/ ❞
library(tidyverse)
devtools::install_github("MSKCC-Epi-Bio/bstfun")
library(bstfun)
library(gtsummary)
library(patchwork)
library(survival)
lm(mpg ~ cyl + am + drat, mtcars) %>%
tbl_regression() %>%
add_inline_forest_plot()
trial %>% select(age, marker) %>%
tbl_summary(missing = "no") %>%
add_sparkline()
tbl <- trial %>% select(age, marker, trt) %>%
tbl_summary(by = trt, missing = "no") %>% as_ggplot()
gg <- trial %>% ggplot(aes(x = age, y = marker, color = trt)) +
geom_point()
gg / tbl
head(trial) %>% gt::gt() %>% style_tbl_compact()
tbl_uvregression(
trial[c("response", "age", "grade")],
method = glm,y = response,
method.args = list(family = binomial),
exponentiate = TRUE) %>% as_forest_plot()
tbl <- coxph(Surv(ttdeath, death) ~ age + marker, trial) %>%
tbl_regression(exponentiate = TRUE) %>% add_n()
as_forest_plot(tbl, col_names = c("stat_n", "estimate", "ci", "p.value"))
tbl %>%
modify_cols_merge(pattern = "{estimate} ({ci})",
rows = !is.na(estimate)) %>%
modify_header(estimate = "HR (95% CI)") %>%
as_forest_plot(col_names = c("estimate", "p.value"),boxsize = 0.2,
col = forestplot::fpColors(box = "darkred"))