Recode specifications appear in a character string, separated by
semicolons (see the examples below), of the form input=output
.
If an input value satisfies more than one specification,
then the first (from left to right) applies.
If no specification is satisfied, then the input value is carried
over to the result. NA
is allowed on input and output.
Several recode specifications are supported:
- single value
For example, 0=NA
.
- vector of values
For example, c(7,8,9)='high'
.
- range of values
For example, 7:9='C'
. The special values lo
and hi
may appear in a range. For example, lo:10=1
. Note: :
is
not the R sequence operator. In addition you may not use :
with the collect operator, so for example c(1, 3, 5:7)
will cause an error.
else
everything that does not fit a previous specification.
For example, else=NA
. Note that else
matches all otherwise
unspecified values on input, including NA
.
If all of the output values are numeric, and if as.factor.result
is
FALSE
, then a numeric result is returned; if var
is a factor,
then by default so is the result.