Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

Arguments

...

vectors/data.frames/lists

x

vector/data.frame/list

y

vector/data.frame/list

Value

vector/data.frame/list

See Also

See also interaction

Examples

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"
)

calc(mtcars, cro(cyl, am %nest% vs))

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

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

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

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

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

expss

Tables, Labels and Some Useful Functions from Spreadsheets and 'SPSS' Statistics

v0.10.7
GPL (>= 2)
Authors
Gregory Demin [aut, cre], Sebastian Jeworutzki [ctb] (<https://orcid.org/0000-0002-2671-5253>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.