Learn R Programming

hydrostats (version 0.2.9)

recode: recode

Description

Recodes values in a vector based on original and new values provided as two vectors.

Usage

recode(x, oldvalue, newvalue)

Arguments

x

A vector with values to be replaced.

oldvalue

A vector of original values to be recoded.

newvalue

A vector of replacement values of the same length as oldvalue.

Value

A vector of same length as input.

Examples

Run this code
# NOT RUN {
x<-seq(1:10)
recode(x, c(1,5,10), c(-1,-5,-10))
# }

Run the code above in your browser using DataLab