Skip to content
Prev 263784 / 398502 Next

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

On Jun 26, 2011, at 00:10 , David Winsemius wrote:

            
Class and mode can also both be "function" or "numeric", but "formula" is not a mode. 

Historically, in S v3, all objects had a mode, but only some had a class, obtained by explicitly adding a "class" attribute. In S v4, the convention that all objects have a class was introduced, and in many cases an object's mode was promoted to become its class (but matrices became of class "matrix"). 

You can learn a lot by simple experimentation. E.g., it may be useful to know that call objects are isomorphic to lists and try things like 

u <- quote(1+3*4)
u[[1]]
u[[2]]
u[[3]]
u[[3]][[1]]


etc. Beware of "false friends": things that look alike but are different, e.g. the call quote(y~x) and the formula that results from evaluating it.
Or evaluating the call, or using as.formula() on it.