Skip to content
Prev 263731 / 398502 Next

What does class "call" mean? How do I make class "formula" into a "call"?

On Jun 25, 2011, at 15:24 , David Winsemius wrote:

            
Actually, no. Any unevaluated expression in R is mode "call", unless atomic or symbol. It will also be class "call", unless expressedly overridden by an S3 class assignment. Notice that operators are really function calls.
I.e.
[1] "call"
[1] "call"

But
[1] "name"
[1] "numeric"

(This is why the R docs keep talking about "unevaluated expressions" instead of "call objects": They aren't always that.)

The "~" operator is also a function call. However, evaluating "~" returns an object which is the actual call assigned class "formula" (plus an environment attribute).
[1] "formula"
y ~ x
attr(,".Environment")
<environment: R_GlobalEnv>
[1] "call"
[1] "call"

I.e., an unevaluated formulae expression (as in quote(y~x)) is class "call", as is an unclassed formula object. So it is pretty easy to have objects of class "formula" very similar to objects of class "call".