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

David Winsemius dwinsemius at comcast.net
Sat Jun 25 15:24:34 CEST 2011


On Jun 24, 2011, at 6:12 PM, StellathePug wrote:

> Hello R Users!
> I have a list called "tabs" that I would like to have the same  
> structure as
> my list "eqSystem." The two look like they have the same structure  
> but they
> are different because when I look at their attributes,  
> class(eqSystem[[1]])
> is "call" but class(tabs[[1]]) is "formula". I want to have  
> class(tabs[[1]])
> as a call too.
>
> So what does "call" mean?

An as yet unevaluated function invocation with first as the named  
function followed by quoted arguments is a "call":

See the help(call) page:

 > f <- round
 > A <- 10.5
 > (g <- as.call(list(f, quote(A))))
.Primitive("round")(A)
 > eval(g)
[1] 10

 > call("mean", quote( c(1,2,3)))
mean(c(1, 2, 3))
 > eval( call("mean", quote( c(1,2,3))))
[1] 2

It seems very unlikely that a formula object could be coerced into a  
valid call simply by altering its class. To convince us otherwise you  
need to provide more information than you have supplied to the  
present. The results of str() on these objects might be a first step.

-- 
David.
>
> And how do I make an object of class "formula" be of class "call"?
> Thank you so much!!!--Rita
>
>
>> class(tabs)
> [1] "list"
>> class(tabs[1])
> [1] "list"
>> class(tabs[[1]])
> [1] "formula"> class(eqSystem)
> [1] "list"
>> class(eqSystem[1])
> [1] "list"
>> class(eqSystem[[1]])
> [1] "call"
>
> Rita
> =====================================
> "If you think education is expensive, try ignorance."--Derek Bok
>
> --
> View this message in context: http://r.789695.n4.nabble.com/What-does-class-call-mean-How-do-I-make-class-formula-into-a-call-tp3623733p3623733.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list