| make_wider | R Documentation |
This function takes a data frame produced by functions like build_table,
build_mtable, or build_qtable, which contains columns N and Percent,
and pivots it into a wider format. It combines the N and Percent columns into
a single xlr_n_percent vector for each pivoted column. If top_variable is not
specified, it infers the variable to use for column names from the structure of the data frame.
make_wider(x, top_variable = NULL, names_prefix = "")
x |
A data frame or tibble containing at least the columns |
top_variable |
Optional. A bare column name to use for the |
names_prefix |
String added to the start of every variable name. This is
particularly useful if |
A xlr_table (if x is a xlr_table) or tibble::tibble (if tibble::tibble or
data.frame) in a wider format with columns containing
xlr_n_percent vectors.
xlr_n_percent, pivot_wider
library(xlr)
# Assuming example data from build_table or similar
table <- clothes_opinions |>
build_table(c(gender,age_group))
make_wider(table)
# use top_variable to specify that we have gender as out selection column
make_wider(table, top_variable = age_group)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.