What is the is.factor() function in R?
is.factor(X)
Parameter value
This function takes a single parameter value, X, which represents any R object.
Return value
This function returns a TRUE or FALSE value.
Example
# creating different R objectsHeight <- factor(c("Tall", "Average", "Short"))my_function <- function() {print("Hello World!")}# checking if they are factors or notis.factor(Height)is.factor(my_function)
Explanation
- Line 2: We use the
factor()function to create an R object,Height.
- Line 3: We use the
function()function to create another R object,myfunction.
- Line 8: We use the
is.factor()function to check if the objectHeightis a factor or not.
- Line 9: We use the
is.factor()function to check if the objectmyfunctionis a factor or not.