Learn R Programming

letsR (version 5.0)

lets.transf: Transform values of a vector

Description

Transform each element of a vector.

Usage

lets.transf(x, y, z, NUMERIC = TRUE)

Value

Return a vector with changed values.

Arguments

x

A vector to be transformed.

y

levels to be transformed.

z

The value to be atributed to each level (same order as y).

NUMERIC

logical, if TRUE z will be considered numbers.

Author

Bruno Vilela

Examples

Run this code
if (FALSE) {
status <- sample(c("EN","VU", "NT", "CR", "DD", "LC"), 30, replace=TRUE) 
TE <- "Threatened"
NT <- "Non-Threatened"
new <- c(TE, TE, NT, TE, "Data Deficient", NT)
old <- c("EN","VU", "NT", "CR", "DD", "LC")
statustrans <- lets.transf(status, old, new, NUMERIC=FALSE)

}

Run the code above in your browser using DataLab