Re: [R] ifelse() and missing values in test conditions

2010-07-20 Thread Hosack, Michael
- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Tuesday, July 20, 2010 1:41 PM To: Hosack, Michael Cc: r-help@r-project.org Subject: Re: [R] ifelse() and missing values in test conditions Hi Mike, Probably the simplest way from what you have done would be to just set any NA values

Re: [R] ifelse() and missing values in test conditions

2010-07-20 Thread Joshua Wiley
Hi Mike, Probably the simplest way from what you have done would be to just set any NA values in the column to 0: DF$ANYEF[is.na(DF$ANYEF)] <- 0 Alternately, you can try this. It should work, but it is far from elegant. DF$ANYEF <- with(DF, ifelse( rowSums(cbind(PSOUGHT1, PSOUGHT2, PSOUGHT3)