fillExpr {crunch} | R Documentation |
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
|
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)