Learn R Programming

JointAI (version 1.1.0)

get_groups: Get grouping information

Description

A helper function that generates grouping information from a data.frame and a character vector with the names of grouping variables. In all cases, the level "lvlone" is added to indicate the lowest level of the data (i.e., each observation is its own group).

Usage

get_groups(idvars, data)

Value

a list with grouping information for each grouping level: each element is a vector of length nrow(data) with the group membership indices of each observation for the corresponding grouping level.

Arguments

idvars

a character vector with the names of grouping variables

data

a data.frame