当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


R语言 as.name()用法及代码示例


as.name()R 语言中的函数用于将参数强制转换为名称。这as.name()as.symbol()函数是相同的。

用法: as.name(x)

参数:
x:被胁迫的对象

范例1:


# 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)

输出:

[1] TRUE

范例2:


# 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)

输出:

[1] "name"

相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Coercing the Argument to a Name in R Programming – as.name() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。