Skip to content
Related Articles

Related Articles

Coercing the Argument to a Name in R Programming – as.name() Function
  • Last Updated : 19 Jun, 2020

as.name() function in R Language is used to coerce the argument to a name. The as.name() and as.symbol() functions are identical.

Syntax: as.name(x)

Parameters:
x: Object to be coerced

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# as.name() function
  
# Calling the as.name() function to
# coerce the argument to a name
x <- as.name("sample")
  
# Calling the is.name() function
# to check whether the argument is
# name or not
is.name(x)

chevron_right


Output:

[1] TRUE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# as.name() function
  
# Calling the as.name() function to
# coerce the argument to a name
x <- as.name("sample")
  
# Getting the class of the argument
class(x)

chevron_right


Output:

[1] "name"
My Personal Notes arrow_drop_up
Recommended Articles
Page :