Complex
A complex value in R is defined via the pure imaginary value i.
> z = 1 + 2i # create a complex number
> z # print the value of z
[1] 1+2i
> class(z) # print the class name of z
[1] "complex"
> z # print the value of z
[1] 1+2i
> class(z) # print the class name of z
[1] "complex"
The following gives an error as −1 is not a complex value.
Instead, we have to use the complex value −1 + 0i.
An alternative is to coerce −1 into a complex value.
Tags: