Re: [R] about vector to the power of a decimal

From: Phil Spector <spector_at_stat.berkeley.edu>
Date: Thu, 12 May 2011 17:10:24 -0700 (PDT)

Please take a look at FAQ 7.33
(http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-are-powers-of-negative-numbers-wrong_003f)

Basically, what you're really calculating is

> -(2^2.1)
[1] -4.287094

You can't raise a negative number to a fractional power, unless you specify it as a complex number

> (-2)^2.1

[1] NaN
> complex(real=-2)^2.1

[1] 4.077269+1.324785i

On Fri, 13 May 2011, 张静思 wrote:

> Hi
> why I can't do this?
> m<-c(1,-2,3)
> m^2.1
> with a negative number in it ,but I can do this to a single negative number like -2^2.1~
> Thank you ~
>
>
> JIngsi
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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 Fri 13 May 2011 - 00:15:23 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Fri 13 May 2011 - 00:40:07 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