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


                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


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

Reply via email to