[R] nth root of matrix

David Winsemius dwinsemius at comcast.net
Wed Jul 3 06:24:59 CEST 2013


On Jul 2, 2013, at 8:11 PM, Sachinthaka Abeywardana wrote:

> Hi all,
> 
> I want to do the following:
> 
> a=matrix(c(-1,-2,-3))
> a^(1/3) #get 3rd root of numbers[,1]
> 
> [1,]  NaN
> [2,]  NaN
> [3,]  NaN
> 
> 
> All I get is NaNs, what is the proper way of doing this? Would like to
> retain the fact that it is a matrix if possible (not a requirement
> though).

?complex

 a=matrix(c(-1+0i,-2+0i,-3+0i))


David Winsemius
Alameda, CA, USA



More information about the R-help mailing list