I'm trying to see if there is a function to directly get the real cube root of a negative number. For example, in Java, there is the Math.cbrt()
function. I'm looking for the equivalent in R.
Otherwise, my current hack is:
x <- -8
sign(x) * abs(x)^(1/3)
which is very inelegant and cumbersome to type every time. Thx!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…