is.factor() function in R Language is used to check if the object passed to the function is a Factor or not. It returns a boolean value as output.
Syntax: is.factor(Object) Parameters: Object: Object to be checkedExample 1:
# Creating a vector
x<-c("female", "male", "male", "female")
# Converting the vector x into a factor named gender
gender<-factor(x)
# Using is.factor() Function
is.factor(gender)
[1] TRUEExample 2:
# Creating a vector
x<-c("female", "male", "male", "female")
# Converting the vector x into a factor named gender
gender<-factor(x)
# Using is.factor() Function
is.factor(x)
[1] FALSE