Re: [R] exponent confusion

From: Phineas Campbell <pcampbell_at_econ.bbk.ac.uk>
Date: Thu 23 Feb 2006 - 04:41:56 EST


> -0.7^1.22

[1] -0.6471718

(-0.7)^1.22
>NaN

Arithmetically this makes perfect sense, syntactically I'm not sure it does.

>z<-c(-0.7)
> z == -0.7

[1] TRUE
> z^1.22

[1] NaN

I remember a programming homily: if you are unsure of the operator precedence then you shouldn't assume the person who has to maintain your code has any better knowledge so you should make the order in which you want expressions to be evaluated explicit.

Phineas

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch]On Behalf Of tom wright Sent: Wednesday, February 22, 2006 10:14 AM To: R-Stat Help
Subject: [R] exponent confusion

please excuse me if this ones a basic error

> y<-c(-0.7,-0.6,-0.5)
> -0.7^1.22
[1] -0.6471718

> y^1.22

[1] NaN NaN NaN

am I missing something important in my basic math?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Feb 23 05:03:40 2006

This archive was generated by hypermail 2.1.8 : Thu 23 Feb 2006 - 06:23:11 EST