-1 has three cube roots (the three solutions to the equation x^3=-1). One of the solutions is -1 and the other two are complex numbers. Going counterclockwise around the complex plane from the positive real axis, the first root is complex, and this is the root that R returns when you work with complex numbers (see below). Since R is not expecting complex numbers in the case of (-1)^(1/3) we need to convert -1 to complex class before taking roots. For example:
as.complex(-1)
#> [1] -1+0i
x = as.complex(-1)^(1/3) # (-1+0i)^(1/3) will also work
x
#> [1] 0.5+0.8660254i
So we now have one cube root of -1. We can get the other two by rotating x by 120 and 240 degrees (\frac{2}{3} \pi and \frac{4}{3} \pi radians) around the origin in the complex plane.
# Multiplying by the number below will rotate a complex number by
# 120 degrees (2*pi/3) about the origin
rot120 = exp(2*pi*(0+1i)/3)
# Get the other two cube roots of -1 by rotating the first cube root by
# 120 degrees and 240 degrees about the origin
x = x * rot120^(0:2)
x
#> [1] 0.5+0.8660254i -1.0+0.0000000i 0.5-0.8660254i
x^3
#> [1] -1+0i -1+0i -1+0i
We can also plot the cube roots to see where they're located in the complex plane. R's plot function understands complex numbers and automatically uses the real parts for the x-axis values and the imaginary parts for the y-axis values.
par(pty="s") # square aspect ratio
# Set up plot region
plot(NA, xlim=c(-1,1), ylim=c(-1,1), asp=1, ylab="Im", xlab="Re", las=1)
clip(-1.05,1.05,-1.05,1.05)
abline(h=0, col="grey50")
abline(v=0, col="grey50")
# Plot cubes of cube roots of -1 (all three equal -1)
points(x^3, pch=16, col="red", cex=2)
# Plot cube roots of -1
points(x, pch=21:23, bg="blue")
