Skip to content
Back to formatted view

Raw Message

Message-ID: <A2D6CB88-8E63-43D0-B7CA-24FCFAFD46BC@u.washington.edu>
Date: 2013-11-01T18:20:58Z
From: Don McKenzie
Subject: extraction of roots in R
In-Reply-To: <CAEVDvzV88AK_NvvXatb4OWrCxPTfkYwF=AFCo+zR=A1-Wcad=w@mail.gmail.com>

If you just want the nth root of X, use X^(1/n)

 > x <- 256
 > x^(1/8)
[1] 2

 > x <- -256
 > x^(1/8)
[1] NaN

It appears that you get the positive real root.

Is this all you wanted?


On 1-Nov-13, at 11:11 AM, Gary Dong wrote:

> Dear R users,
>
> I wonder if R has a default function that I can use to do  
> extraction of
> roots.
>
> Here is an example:
>
> X                  N
> 2.5              5
> 3.4              7
> 8.9              9
> 6.4              1
> 2.1              0
> 1.1             2
>
> I want to calculate Y = root(X)^N, where N represents the power.  
> what is
> the easy way to do this?
>
> Thank you!
>
> Gary
>
> 	[[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.





Don McKenzie
Pacific Wildland Fire Sciences Lab
US Forest Service

Affiliate Professor
School of Environmental and Forest Sciences
University of Washington

dmck at uw.edu