[R] one is not one
Patrick Giraudoux
patrick.giraudoux at univ-fcomte.fr
Sat Oct 21 11:04:13 CEST 2006
Folks,
I have got a strange behaviour when testing this:
sum(x) != 1
let us set
x<-c(70,134,1,5,0)
and transform it in a vector of probabilities
x<-x/sum(x)
One expect sum(x) should be equal to 1, which is apparently the case
> sum(x)
[1] 1
However, when I try to test it I get:
> if(sum(x) !=1) print("lost") else ("OK")
[1] "lost"
Which means that actually sum(x) is NOT considered equal to 1...
Any idea about what is going wrong?
Patrick
More information about the R-help
mailing list