Transform each element of a vector.
lets.transf(x, y, z, NUMERIC = TRUE)
Return a vector with changed values.
A vector to be transformed.
levels to be transformed.
The value to be atributed to each level (same order as y).
logical, if TRUE
z will be considered numbers.
Bruno Vilela
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