mat_head_group: Take first groups

mat_head_groupR Documentation

Take first groups

Description

Take first groups

Usage

mat_head_group(df, ..., n_head = 5, slice = FALSE)

Arguments

df

data

...

grouping vars

n_head

Number of groups

slice

Whether n_head indicates row position

Examples

df <- data.frame(group_a = rep(LETTERS[1:3], each=4),
                 group_b = rep(letters[1:2], 6),dat = 1:12)
mat_head_group(df, group_a, n_head=1)
mat_head_group(df, group_a, group_b, n_head=1)

## Use as slice: select second group only, not up to 2:
mat_head_group(df, group_a, n_head=2, slice=TRUE)
mat_head_group(df, group_a, n_head=c(2,3), slice=TRUE)

MatthieuStigler/matPkg documentation built on Nov. 13, 2023, 7:53 p.m.