Skip to content
Prev 255991 / 398506 Next

Need a more efficient way to implement this type of logic in R

Walter -
    Since your codes represent numbers, you could use something like
this:

chk = as.numeric((hh.sub$HHFAMINC)
hh.sub$CS_FAMINC = cut(chk,c(-10,0,5,10,15,17,18),labels=c(0,1:5))

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Wed, 6 Apr 2011, Walter Anderson wrote: