Skip to content
Prev 255988 / 398506 Next

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

On 06/04/2011 4:02 PM, Walter Anderson wrote:
The answer is to think in terms of vectors and logical indexing.  The 
code above is equivalent to

hh.sub$CS_FAMINC[ hh.sub$HHFAMINC %in% c('01', '02', '03', '04', '05') ] 
<- 1

I've left off the rest of the loop, but I think it's similar.

Duncan Murdoch