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

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to