[R] the ifelse function

Chuck Cleland ccleland at optonline.net
Sun May 6 04:00:18 CEST 2007


Jennifer Dillon wrote:
> Hi Everyone,
> 
> I think I found a problem with the ifelse function:  If the condition
> argument is NA, it treats it as true.  Anyone agree or disagree with this?

  I disagree.

> ifelse(c(5,4,NA) == 5, 1, 0)
[1]  1  0 NA

> Jen

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list