flipArrays {crunch}R Documentation

Rearrange array subvariables

Description

Sometimes it is useful to group subvariables across arrays in order to compare them more easily. This function generates a set of derived views of common subvariables across arrays. Because they are derived, they share data with the underlying array variables, and they are thus automatically updated when new data is appended.

Usage

flipArrays(variables, suffix = ", flipped")

Arguments

variables

List of variables, a variable catalog, or a dataset subset containing the categorical array or multiple response variables you want to rearrange.

suffix

character string to append to the new variable names. Pass "" if you don't want it to append anything.

Value

A list of derived VariableDefinitions, one per unique subvariable name across all variables. Each variable in variables that contains this subvariable will appear as a subvariable in these new derived array definitions. Use addVariables to add these to your dataset.

Examples

## Not run: 
ds <- addVariables(ds, flipArrays(ds[c("petloc", "petloc2")], suffix = ", rearranged"))

## End(Not run)

[Package crunch version 1.30.4 Index]