Skip to content
Related Articles

Related Articles

Check if an Object is of Complex Data Type in R Programming – is.complex() Function
  • Last Updated : 16 Jun, 2020
GeeksforGeeks - Summer Carnival Banner

is.complex() function in R Language is used to check if the object passed to it as argument is of complex data type.

Syntax: is.complex(x)

Parameters:
x: Object to be checked

Example 1:




# R program to check if 
# object is of complex type
  
# Calling is.complex() function
is.complex(1 + 0i)
is.complex(1.5 + 2i)
is.complex(-1.5 + 2i)

Output:



[1] TRUE
[1] TRUE
[1] TRUE

Example 2:




# R program to check if 
# object is of complex type
  
# Creating a vector
x1 <- (rep(1:4) + 1i*(4:1))
x1
  
# Calling is.complex() function
is.complex(x1)

Output:

[1] 1+4i 2+3i 3+2i 4+1i
[1] TRUE

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :