nalevs {weights} | R Documentation |
Recode variables to 0-1 scale
Description
nalevs
takes as an input any vector and recodes it to range from 0 to 1, to treat specified levels as missing, to treat specified levels as 0, 1, .5, or the mean (weighted or unweighted) of the levels present after coding.
Usage
nalevs(x, naset=NULL, setmid=NULL, set1=NULL, set0=NULL,
setmean=NULL, weight=NULL)
Arguments
x |
A vector to be recoded to range from 0 to 1. |
naset |
A vector of values of |
setmid |
A vector of values of |
set1 |
A vector of values of |
set0 |
A vector of values of |
setmean |
A vector of values of |
weight |
A vector of weights for |
Value
A vector of length equal to that of x
of class numeric
.
Author(s)
Josh Pasek, Assistant Professor of Communication Studies at the University of Michigan (www.joshpasek.com).
Examples
data(anes04)
summary(anes04$age)
summary(nalevs(anes04$age))
table(anes04$educcats)
table(nalevs(anes04$educcats, naset=c(2, 4)))