[R] ifelse behavior

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Sep 2 16:43:11 CEST 2002


Stephan Holl <sholl at gmx.net> writes:

> > str(blah$index.s)
>  num 100
> > 
> everything seems OK.
> when I do a ifelse-check, something strange happens:
> > ifelse(blah$index.s == 100 ,1,2)
> [1] 2
> 
> When I replace the blah$index.s with 100 like the following line does
> > blah$index.s <-  100
> > str(blah$index.s)        
>  num 100
> it is a numeric value as well, but the result of the ifelse-check is
> different!!
> > ifelse(blah$index.s == 100 ,1,2)
> [1] 1
> that's the result which is correct!
> 
> Can anybody explain this behavior please ?!

What happens if you say 

blah$index.s - 100 

in the two cases?
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list