Learn R Programming

MAPCtools (version 0.1.0)

expected_groups: Find expected groups based on distinct values across a set of variables

Description

Given a data frame and a set of discrete (or factor) variables, returns all combinations of their observed levels and the list of levels.

Usage

expected_groups(data, vars)

Value

A named list with two elements:

grid

A data.frame where each row is one combination of the variable levels (equivalent to what expand.grid would produce).

levels

A named list; for each variable in vars it gives the sorted unique values (or factor levels) observed in data.

Arguments

data

A data frame whose columns you want to examine.

vars

Character vector of column names in data to use.