Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

r
communitycreator

What is the as.name() function in R?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The as.name() function in R converts a given R object into a name class object.

The name class object has the class "name". class(name_object) returns the name of the class from which the R object is inherited.

Syntax

as.name(value)

Parameter value

The as.name() function takes the parameter value, value, which represents the R object.

Return value

The as.name() function returns a name class object.

Code example

# creating an R object
number <- 123
# printing the value stored in number
number
# calling the as.name() function
name_object = as.name(number)
# printing the name class object
name_object
# checking if its a name class object
is.name(name_object)
# checking the class
class(name_object)
Simple example using the as.name() function

Code explanation

  • Line 2: We create a variable number.
  • Line 5: We print the value stored in variable number.
  • Line 8: We implement the as.name() function on the number variable. The result is assigned to a variable name_object.
  • Line 11: We print the variable name_object.
  • Line 14: We use the is.name() function and check if the variable, name_object is a name class object.
  • Line 17: We use the class() function we returned the class of the object name_object.

RELATED TAGS

r
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring