R语言 检查参数是否是一个名字 – is.name() 函数
R语言中的 is.name() 函数用于返回TRUE,如果参数是名字,则返回FALSE。 is.name() 和 is.symbol() 函数是相同的。
语法: is.name(x)
参数:
x: 要测试的R对象
例1 :
# R program to illustrate
# is.name() function
# Initializing a string
x <- "sample"
# Calling the is.name() function
# to check whether the argument is
# name or not
is.name(x)
输出
[1] FALSE
例2 :
# R program to illustrate
# is.name() function
# Coercing 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