Skip to content
Prev 304110 / 398513 Next

ifelse problem - bug or operator error

AAAAAHHHHHHH I GOT IT!!!!!!!!!!

And I *think* I understand about floating point arithmetic..

In this case vn$PM.DIST.TOT is the sum of proportions.  So, it should
be anywhere 0 and 1.

In our case, if it's anything other than 1 when vn$PM.EXP is greater
than 0  then it means something is wrong with one of the variables
used to sum vn$PM.DIST.TOT.

I was worried making it an integer will cause cases of 0.4 to be 0 and
look legal, when it's not (though it doesn't actually seem to be a
problem).

So, I just did what Michael and Peter suggested, after reading up on
floating points.

fpf <- 1e-05   # fpf = floating point fuzz

vn$PM.DIST_flag<-ifelse(vn$PM.EXP > 0 & abs(vn$PM.DIST.TOT - 1) > fpf , 1, 0)

YAAAAAYYYYY!!!!

Thanks, solved AND I learned something new.

Thanks, alll, and have a GREAT weekend!

Jen
On Fri, Aug 24, 2012 at 6:27 PM, Peter Ehlers <ehlers at ucalgary.ca> wrote: