Learn R Programming

expss (version 0.11.4)

nest: Compute nested variable(-s) from several variables

Description

nest mainly intended for usage with table functions such as cro. See examples. %nest% is infix version of this function. You can apply nest on multiple-response variables/list of variables and data.frames.

Usage

nest(...)

x %nest% y

Value

vector/data.frame/list

Arguments

...

vectors/data.frames/lists

x

vector/data.frame/list

y

vector/data.frame/list

See Also

See also interaction

Examples

Run this code
data(mtcars)

mtcars = apply_labels(mtcars,
                      cyl = "Number of cylinders",
                      vs = "Engine",
                      vs = num_lab("
                             0 V-engine 
                             1 Straight engine
                             "),
                      am = "Transmission",
                      am = num_lab("
                             0 Automatic 
                             1 Manual
                             "),
                      carb = "Number of carburetors"
)

cross_cases(mtcars, cyl, am %nest% vs)

# list of variables
cross_cases(mtcars, cyl, am %nest% list(vs, cyl))

# list of variables - multiple banners/multiple nesting
cross_cases(mtcars, cyl, list(total(), list(am, vs) %nest% cyl))

# three variables 
cross_cases(mtcars, am %nest% vs %nest% carb, cyl)

# the same with usual version
cross_cases(mtcars, cyl, nest(am, vs))

# three variables 
cross_cases(mtcars, nest(am, vs, carb), cyl)

Run the code above in your browser using DataLab