Re: [R] WIERD: Basic computing in R

From: Mark Lyman <mark.lyman_at_gmail.com>
Date: Tue, 01 Jul 2008 18:27:56 +0000 (UTC)

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 01 Jul 2008 - 18:51:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 01 Jul 2008 - 19:31:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive