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

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[1] TRUE
[1] FALSE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# 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)

chevron_right


Output:

[1] TRUE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.