as_ggplot: Convert gt/gtsummary table to ggplot

Description Usage Arguments Value Examples

View source: R/as_ggplot.R

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

1

Arguments

x

gt or gtsummary table

...

arguments passed to gt::gtsave()

Value

a ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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 May 4, 2021, 9:39 a.m.