Last chance! 50% off unlimited learning
Sale ends in
Unites targeted table columns into a pair of name-level columns.
uniteNameLevel(
x,
cols = character(0),
name = "group_name",
level = "group_level",
keep = FALSE,
ignore = c(NA, "overall")
)
A tibble with the new columns.
A dataframe.
Columns to aggregate.
Column name of the name
column.
Column name of the level
column.
Whether to keep the original columns.
Level values to ignore.
x <- dplyr::tibble(
variable = "number subjects",
value = c(10, 15, 40, 78),
sex = c("Male", "Female", "Male", "Female"),
age_group = c("<40", ">40", ">40", "<40")
)
x |>
uniteNameLevel(
cols = c("sex", "age_group"),
name = "new_column_name",
level = "new_column_level"
)
Run the code above in your browser using DataLab