If I generate a vector of values, some of which are negative:
d <- rnorm(1000, 4, 10)
z <- sapply(d, function(x) x^1.2)
z will contain a mix of real values and NaNs. Any values that were originally negative in the vector will be NaN.
Why is this? How can I fix it?
You should use
complexnumbers, like below