R/recode.R

Defines functions recode

# given a vector and a recode matrix replace the values in 'x' that match in
# 'm[,1]' with the corresponding replacements from 'm[,2]'

recode <- function(x, mat)
{
    i <- match(x, mat[,1])
    i2 <- which(!is.na(i))
    i <- i[i2]
    rval <- x
    rval[i2] <- mat[,2][i]
    rval
}

Try the intergraph package in your browser

Any scripts or data that you put into this service are public.

intergraph documentation built on Aug. 21, 2023, 1:06 a.m.