Skip to content
Prev 301973 / 398503 Next

Help with NaN when 0 divided by 0

I think this would be more to the point if the output were set to 0
if the numerator were 0, not if the output would be NA. 
   res[x==0] <-0

You may also want to restructure your computations so that
the proportion resulting from 0/0 remains as NaN but when
you multiply the proportion by a total you set the result to be 0
if the total is 0.  (If the total is not 0 you may want to signal
an error.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com