Open In App

Check if Object is of the Character Data type in R Programming – is.character() Function

Last Updated : 03 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads