recode: Recode Values

Description Usage Arguments Value References Examples

Description

Assign new values to a vector.

Usage

1
recode(x, old, new, must.match = FALSE)

Arguments

x

A vector whose values will be recoded, can be character, numeric, or factor.

old

A vector of the unique values currently in the vector.

new

A vector of values which should replace the current ones.

must.match

A logical scalar indicating whether only those elements of the original vector with values in old should be returned (TRUE), or all values should be returned (FALSE, default) though some may be unchanged.

Value

A vector the same length as x (unless must.match=TRUE), with old values replaced by new values.

References

This is a copy of the recode function from the [jvamisc] package.

Examples

1
2
recode(c(1,1,1,2,3,4,1,10,3), 1:3, 1001:1003)
recode(c(1,1,1,2,3,4,1,10,3), 1:3, 1001:1003, must.match=TRUE)

JVAdams/artiFISHal documentation built on May 7, 2019, 10:14 a.m.