Skip to content
Related Articles

Related Articles

Check if Object is of the Character Data type in R Programming – is.character() Function
  • Last Updated : 03 Jun, 2020

is.character() Function in R Language is used to check if the object is of the form of a string/character or not. It will return true if any element of the object is of the character data type.

Syntax: is.character(Object)

Parameter:
Object: It could be an array, list, vector, etc.

Example 1:




# R Program to illustrate 
# the use of is.character function
  
# Creating a vector of mixed datatype
x1 <- c("Hello", "Geeks", 100)
  
# Creating a vector of Numeric datatype
x2 <- c(10, 20, 30)
  
# Calling is.character() function
is.character(x1)
is.character(x2)

Output:

[1] TRUE
[1] FALSE

Example 2:




# R Program to illustrate 
# the use of is.character function
  
# Create the vectors with different length 
vector1 <- c(1, 2, 3
vector2 <- c("GFG", "Geeks", "Hello"
    
# taking this vector as input 
result <- array(c(vector1, vector2), dim = c(3, 3, 2)) 
  
# Calling is.character() function
is.character(result)

Output:

[1] TRUE
My Personal Notes arrow_drop_up
Recommended Articles
Page :