Combine N and Percent Columns for Accessibility
combine_n_pct(df, n, pct, name, remove = TRUE, na_replace = NULL)
A data frame that has already been sent to fmt_table()
The unquoted name of the column containing count values
The unquoted name of the column containing percentage values
The name of the new combined column to be created
Logical. Should the existing n
and pct
columns be removed?
Character string representing how missing values should be represented.
A data frame.
pcts <- tibble::tibble(Program = c("A", "B", "C", "D", "E", "F"),
n = 0:5,
p = 0.5 * (0:5))
pcts |>
fmt_table() |>
combine_n_pct(n = n, pct = p, name = "States")
#> # A tibble: 6 × 2
#> Program States
#> <chr> <chr>
#> 1 A "0\\ <(0.1)\\ \\ "
#> 2 B "1\\ (0.5)"
#> 3 C "2\\ (1.0)"
#> 4 D "3\\ (1.5)"
#> 5 E "4\\ (2.0)"
#> 6 F "5\\ (2.5)"