R/revcode.R

Defines functions revcode

Documented in revcode

#reverse coding
revcode <- function(data, vars){
 x <- length(vars)
 for (i in 1:x){
 mx <- max(data[,vars[i]])
 mn <- min(data[,vars[i]])
 data[,vars[i]] <- (mx) - data[,vars[i]] + (mn)
}
return(data)
}

Try the gendata package in your browser

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

gendata documentation built on May 10, 2022, 1:05 a.m.