Function converts a gtsummary object to a tibble.
# S3 method for gtsummary
as_tibble(
x,
include = everything(),
col_labels = TRUE,
return_calls = FALSE,
fmt_missing = FALSE,
...
)
# S3 method for gtsummary
as.data.frame(...)
Object created by a function from the gtsummary package (e.g. tbl_summary or tbl_regression)
Commands to include in output. Input may be a vector of
quoted or unquoted names. tidyselect and gtsummary select helper
functions are also accepted.
Default is everything()
.
Logical argument adding column labels to output tibble.
Default is TRUE
.
Logical. Default is FALSE
. If TRUE
, the calls are returned
as a list of expressions.
Logical argument adding the missing value formats.
Not used
a tibble
Other gtsummary output types:
as_flex_table()
,
as_gt()
,
as_hux_table()
,
as_kable_extra()
,
as_kable()
# \donttest{
tbl <-
trial %>%
select(trt, age, grade, response) %>%
tbl_summary(by = trt)
as_tibble(tbl)
#> # A tibble: 8 × 3
#> `**Characteristic**` `**Drug A**, N = 98` `**Drug B**, N = 102`
#> <chr> <chr> <chr>
#> 1 Age 46 (37, 59) 48 (39, 56)
#> 2 Unknown 7 4
#> 3 Grade NA NA
#> 4 I 35 (36%) 33 (32%)
#> 5 II 32 (33%) 36 (35%)
#> 6 III 31 (32%) 33 (32%)
#> 7 Tumor Response 28 (29%) 33 (34%)
#> 8 Unknown 3 4
# without column labels
as_tibble(tbl, col_labels = FALSE)
#> # A tibble: 8 × 3
#> label stat_1 stat_2
#> <chr> <chr> <chr>
#> 1 Age 46 (37, 59) 48 (39, 56)
#> 2 Unknown 7 4
#> 3 Grade NA NA
#> 4 I 35 (36%) 33 (32%)
#> 5 II 32 (33%) 36 (35%)
#> 6 III 31 (32%) 33 (32%)
#> 7 Tumor Response 28 (29%) 33 (34%)
#> 8 Unknown 3 4
# }