It is important to understand what is.symbol and is.name . Firstly, it is really the same function. notice, that
is.symbol # function (x) .Primitive("is.symbol") is.name # function (x) .Primitive("is.symbol")
so the characters / names are really the same thing in R. So here I just use is.name
But also note that these functions check if the "subject" is that the name you pass in points is a symbol or name. They are looking for what the name indicates.
So if you did
You will get an error message. Despite the fact that foo is the name itself, what it points to is not yet defined. He is trying to "find" the meaning of foo . notice, that
quote(foo) # foo is.name(quote(foo)) # [1] TRUE
So, quote will treat the parameter as a language object, and you can check it this way. Now, if we define foo to specify a name
(foo <- as.name("hello"))
but if we point to something else
(foo <- "hello") # [1] "hello" is.name(foo) # [1] FALSE is.character(foo) # [1] TRUE
then it no longer points to a name (here it points to a symbol)
Thus, variable names are names / characters, but usually most of the functions of R will work with what they point to, and not return information about the name itself. So the problem was that you misinterpreted the work of is.name and is.symbol . It really really matters when you program in a language.
Mrflick
source share