[R] WIERD: Basic computing in R

Mark Lyman mark.lyman at gmail.com
Tue Jul 1 20:27:56 CEST 2008


poolloopus <at> yahoo.com <poolloopus <at> yahoo.com> writes:

> 
> Can someone please enlighten me as to why the following happens?
> > -2.7^8.6
> [1] -5125.407
> 
> > p<- -2.7
> > q<- 8.6
> > p^q
> [1] NaN
> R seems perfectly able to calculate -2.7^8.6, but fails when the exact same 
values are assigned to
> variables and then the computation is repeated. 
> Thanks in advance for any suggetsions.
> Kris.


The problem is the grouping is not what you are expecting it is. Try

(-2.7)^8.6

and

p <- 2.7
q <- 8.6
p^q

Mark



More information about the R-help mailing list