recode: Recode variable

Description Usage Arguments See Also Examples

View source: R/recode.R

Description

Recode a vector from chosen values to new values. Any value not existing in from vector will be recoded to other. Numeric vector can be truncated.

Usage

1
recode(x, from, to, other, truncate = TRUE, margin = 0.5)

Arguments

x

vector.

from

source values.

to

target values.

other

if provided, other values are recoded to other.

truncate

if TRUE values below min and above max of the to vector are recoded to min and max respectively. See: trun.

margin

see: trun.

See Also

trun

Examples

1
2
recode(1:10, from=3:5, to=5:3, truncate=TRUE)
recode(1:10, from=3:5, to=5:3, other=NA)

twolodzko/equi documentation built on Nov. 11, 2020, 4:04 p.m.