Given x<--3, I tried to get its square root (I know it should be an imaginary number), but it seems not working:
> sqrt(x)
[1] NaN
Warning message:
In sqrt(x) : NaNs produced
Is there any way to make it fly? Thanks!
You should use as.complex
> sqrt(as.complex(x))
[1] 0+1.732051i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With