as_ggplot: Convert gt/gtsummary table to ggplot

View source: R/as_ggplot.R

as_ggplotR Documentation

Convert gt/gtsummary table to ggplot

Description

useful when you want to place a ggplot and gt table side-by-side. To use this function you must install the magick R package AND system program (see https://docs.ropensci.org/magick/articles/intro.html#installing-magick-1)

Usage

as_ggplot(x, ...)

Arguments

x

gt or gtsummary table

...

arguments passed to gt::gtsave()

Value

a ggplot object

See Also

Other gtsummary-related functions: add_inline_forest_plot(), add_sparkline(), bold_italicize_group_labels(), logistic_reg_adj_diff(), style_tbl_compact(), tbl_likert(), theme_gtsummary_msk()

Examples

library(gtsummary)
library(ggplot2)
library(patchwork)

# # convert gtsummary table to ggplot
# tbl <-
#  trial %>%
#  select(age, marker, trt) %>%
#  tbl_summary(by = trt, missing = "no") %>%
#  as_ggplot()
#
# # create basic ggplot
# gg <-
#  trial %>%
#  ggplot(aes(x = age, y = marker, color = trt)) +
#  geom_point()
#
# # stack tables using patchwork
# gg / tbl

ddsjoberg/bstfun documentation built on July 4, 2023, 10:59 a.m.