Get a derived variable's derivation formula as a CrunchExpr with
derivation(variable)
. Set (change) a derived variable's derivation with
derivation(variable) <- expression
.
# S4 method for CrunchVariable
derivation(x)# S4 method for CrunchVariable,ANY
derivation(x) <- value
# S4 method for CrunchVariable,`NULL`
derivation(x) <- value
# S4 method for CrunchVariable
is.derived(x)
# S4 method for CrunchVariable,logical
is.derived(x) <- value
a variable
a CrunchExpr
to be used as the derivation (for the setter
only) or NULL
to integrate a derived variable. For is.derived
, FALSE
can be used to integrate a derived variable.
a CrunchExpr
of the derivation for derivation
; a logical for
is.derived
; the variable given in x
for is.derived<-
returns
To break a derivation link between a derived variable and the originating variable, set
the derivation value of the derived variable to NULL
with derivation(variable) <- NULL
is.derived
can be used to see if a variable is derived or not. Additionally
setting a derived variable's is.derived
to FALSE
will break the derivation link between
two variables.
# NOT RUN {
ds$derived_v1 <- ds$v1 + 5
derivation(ds$derived_v1)
# Crunch expression: v1 + 5
derivation(ds$derived_v1) <- ds$v1 + 10
derivation(ds$derived_v1)
# Crunch expression: v1 + 10
is.derived(ds$derived_v1)
# TRUE
# to integrate or instantiate the variable in place (remove the link between
# variable v1 and the derivation) you can:
derivation(ds$derived_v1) <- NULL
# after integrating, the derived variable is no longer derived.
is.derived(ds$derived_v1)
# FALSE
# }
Run the code above in your browser using DataLab