Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] R: to the power

allan sta staff sci main uct

2005-07-12

Replies:

hi all

why does R do this:

(-8)^(1/3)=NaN

the answer should be : -2

a silly question but i kept on getting errors in some of my code due to this
problem.

i solve the problem as follows:

say we want : (-a)^(1/3)

then : sign(a)*(a^(1/3)) works

but there has to be a simpler way of soing such a simple mathematical operation.

thanking you
/
allan

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.