NaN error in calculation

Hi everyone,

I can´t seem to figure out why the following calculation returns the error "NaN".


The exact same calculation in typed into Microsoft excel works just fine.

Any hints would be much appreciated.

Order of operations must be different. R seems to be doing the exponentiation before the negation while Excel does it the other way around. (You can add parentheses to control this if you like.)

1 Like

Looks like it all stem from this


or more simply


R raises -0.5 to the power 0.88 which is an imaginary number.

For some reason, Excel applies the negative to the quantity before the exponent, so is evaluating 0.5^0.88.

I'd take a look at that part of the equation and re-write so it is more explicit what that first "-" is supposed to do.

1 Like

I see, thanks a lot. Adding parenthesis did the job.

Sorry for wasting your time with this one!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.