[R] RES: WIERD: Basic computing in R

From: Leandro Marino <leandro_at_cesgranrio.org.br>
Date: Tue, 01 Jul 2008 15:47:39 -0300


Hi,

the problem is what you want!

With the -2.7^8.6 you are doing -(2.7^8.6) it exists...

But, if you try (-2.7)^8.6 the R gives you NaN. When you define p=-2.7 and q=8.6 and do p^q you are doing that (-2.7)^8.6.

If you write p=2.7 and q=8.6 and use the -p^q it will work!

Leandro Marino
www.leandromarino.com.br

-----Mensagem original-----
De: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org]Em nome de Dirk Eddelbuettel
Enviada em: terca-feira, 1 de julho de 2008 15:19 Para: poolloopus_at_yahoo.com
Cc: r-help_at_r-project.org
Assunto: Re: [R] WIERD: Basic computing in R

On Tue, Jul 01, 2008 at 11:15:58AM -0700, poolloopus_at_yahoo.com wrote:
> 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.

Try

        -(p^q)

Dirk

--
Three out of two people have difficulties with fractions.

______________________________________________
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.

______________________________________________
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 - 19:04:24 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