group_equal: Group Equal

Description Usage Arguments Examples

View source: R/group_equal.R

Description

Split a dataframe column into equal-sized groups.

Usage

1
group_equal(df, col, n_groups = 5, add_first_last = TRUE)

Arguments

df

A dataframe

col

A numeric column. If the value here is outside the vector range, the 'group' colum will be set to NA for that row.

n_groups

Number of groups to end.

add_first_last

Should the first and last element be included?

Examples

1
2
groups <- group_equal(mtcars, "mpg", n_groups = 5)
dobtools::group_numeric(mtcars, "mpg", groups, add_first_last = TRUE)

aedobbyn/dobtools documentation built on May 28, 2019, 2:33 a.m.