R/recode.R

Defines functions recode

Documented in recode

recode <-
function(vec,original,modified) {
    if (length(original) != length(modified)) stop("original & modofied lengths differ")
    rvec<-vector(mode=mode(vec),length=length(vec))
    is.na(rvec)<-TRUE
    for (k in 1:length(original)) {
      rvec[vec==original[k]]<-modified[k]
    }
    return(rvec)
  }

Try the lordif package in your browser

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

lordif documentation built on May 2, 2019, 2:13 p.m.