Complete the code to create a complex number with real part 3 and imaginary part 4.
z <- complex(real = [1], imaginary = 4)
The complex() function creates a complex number. The real part is 3, so we fill in 3.
Complete the code to get the imaginary part of the complex number z.
imag_part <- [1](z)Re() which returns the real part.Mod() which returns the magnitude.The function Im() returns the imaginary part of a complex number in R.
Fix the error in the code to create a complex number with real part 2 and imaginary part 5.
z <- complex([1] = 2, imaginary = 5)
imaginary for the real part.im or imag.The correct argument name for the real part in complex() is real.
Fill both blanks to create a vector of complex numbers with real parts 1 to 3 and imaginary parts 4 to 6.
z_vec <- complex(real = [1], imaginary = [2])
Use 1:3 for real parts and 4:6 for imaginary parts to create the vector.
Fill all three blanks to create a named list of complex numbers where keys are uppercase letters and values are complex numbers with real parts 1 to 3 and imaginary parts 3 to 5.
names <- toupper(letters[1:3]) values <- complex(real = [1], imaginary = [2]) complex_list <- setNames([3], names)
Use 1:3 for real parts, 3:5 for imaginary parts, and the variable values as the list elements.