What is the is.name() function in R?
Overview
In R, the is.name() function is used to return a logical value, TRUE or FALSE, indicating whether an argument passed to it is a name class object.
Note: A name class object has the class"name".
Syntax
is.name(x)
Syntax for the is.name() function
Parameter
This function takes the argument x, which represents the value we want to check.
Return value
This function returns TRUE if the argument passed to it is a name. Otherwise, it returns FALSE.
Example
# cretating R objectsa <- as.name("Theo")b <- as.integer(2)# impementing the is.name() functionis.name(a)is.name(b)
Explanation
- Line 2: We create a variable,
a, using theas.name()function. Theas.name()function converts the object,a, to a name class object.
- Line 3: We use the
as.integer()function to create another variableb.
- Line 6–7: We implement the
is.name()function on both variables to check if they arenameclass object or not.