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 objects
a <- as.name("Theo")
b <- as.integer(2)
# impementing the is.name() function
is.name(a)
is.name(b)

Explanation

  • Line 2: We create a variable, a, using the as.name() function. The as.name() function converts the object, a, to a name class object.
  • Line 3: We use the as.integer() function to create another variable b.
  • Line 6–7: We implement the is.name() function on both variables to check if they are name class object or not.

Free Resources