Learn R Programming

expss (version 0.7.1)

nest: Compute nested variable from several variables

Description

nest mainly intended for usage with table functions such as cro. See examples. %nest% is infix version of this function. Multiple-response variable are supported in this function..

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

Run this code
# NOT RUN {
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"
)

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

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

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

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

Run the code above in your browser using DataLab