Learn R Programming

omopgenerics (version 1.1.1)

uniteGroup: Unite one or more columns in group_name-group_level format

Description

Unites targeted table columns into group_name-group_level columns.

Usage

uniteGroup(x, cols = character(0), keep = FALSE, ignore = c(NA, "overall"))

Value

A tibble with the new columns.

Arguments

x

Tibble or dataframe.

cols

Columns to aggregate.

keep

Whether to keep the original columns.

ignore

Level values to ignore.

Examples

Run this code
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 |>
  uniteGroup(c("sex", "age_group"))

Run the code above in your browser using DataLab