Brian
Brian

Reputation: 349

Can R handle complex numbers

I am confused how this works

> -2.2^(1-2.2)
[1] -0.3882333

But this does not

> x= -2.2
> x^(1+x)
[1] NaN

Upvotes: 0

Views: 443

Answers (1)

zuiqo
zuiqo

Reputation: 1199

Yes. Use complex: `

z <- complex(real = x, imaginary = y)

z

# [1] 1+1i

`

Source: http://www.johnmyleswhite.com/notebook/2009/12/18/using-complex-numbers-in-r/

Upvotes: 4

Related Questions