What is the is.character() function in R?

In R, the character objects represent string values. The as.character() function transforms the values into character objects. We can use the is.character() function to determine whether the provided object is a character as follows:

Syntax

is.character(object)
The syntax for the is.character() function in R

Parameters

The is.character() function takes a single parameter value, representing the object whose type we want to determine.

Return value

The is.character() function returns TRUE if the provided object is a character. Otherwise, it returns FALSE.

Example

# Vector of character datatype
vec1 <- c("Welcome", "to", "Educative!")
# Vector of numeric datatype
vec2 <- c(1, 0, 1)
# Using the is.character() function
is.character(vec1)
is.character(vec2)

Explanation

  • Line 2: We create a vector vec1 of character datatypes.

  • Line 4: We create a vector vec2 of numeric datatypes.

  • Lines 6–7: We use is.character() to determine the type of created objects.

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved