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

fillExpr

Expression to fill a variable from another


Description

Given a categorical variable, assign one or more categories to be filled in by another existing variable or crunch expression. (Categories not filled in will remain unchanged ).

Usage

fillExpr(x, fills, ..., data = NULL, type = NULL)

Arguments

x

a Categorical (Array) variable

fills

a list of lists that each have a "fill" item that is a variable or expression as well as one of an "id", "name", or "value" that will be matched to the categories of x If x is an expression, the fills must be an id

...

A sequence of named expressions or variables to use as fills, where the name will be matched to the existing categories

data

(optional) a crunch dataset to use. Specifying this means you don't have to put dataset$ in front of each variable name

type

The type of the variable to output (either "categorical" or "numeric"), only required if all fills are expressions and so their type cannot be guessed automatically.

Value

A CrunchExpression that assigns categories to filling variables

Examples

## Not run: 
fillExpr(
    ds$v1,
    fills = list(
        list(fill = ds$v2, name = "dog")
    )
)
fillExpr(v1, "dog" = ds$v2)

# the dataset can be specified with data=
fillExpr(v1, "dog" = v2, data = ds)

## End(Not run)

crunch

Crunch.io Data Tools

v1.28.0
LGPL (>= 3)
Authors
Greg Freedman Ellis [aut, cre], Jonathan Keane [aut], Mike Malecki [aut], Neal Richardson [aut], Gordon Shotwell [aut]
Initial release

We don't support your browser anymore

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