[R] building lme call via call()

William Dunlap wdunlap at tibco.com
Mon Oct 25 19:28:12 CEST 2010



Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Vito Muggeo (UniPa)
> Sent: Monday, October 25, 2010 9:16 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] building lme call via call()
> 
> dear all,
> I would like to get the lme call without fitting the relevant model.
> 
> library(nlme)
> data(Orthodont)
> fm1 <- lme(distance ~ age, random=list(Subject=~age),data = Orthodont)
> 
> To get fm1$call without fitting the model I use call():
> 
> my.cc<-call("lme.formula", fixed= distance ~ age, random = 
> list(Subject 
> = ~age))
> 
> However the two calls are not the same (apart from the data 
> argument I 
> am not interested in), as call() *does* evaluate the arguments:
> 
>  > my.cc$random
> $Subject
> ~age

You can use quote() to avoid the evaluations.  E.g.,
  > better.cc <- call("lme.formula",
  +                   fixed=quote(distance~age),
  +                   data=quote(Orthodont),
  +                   random=quote(list(Subject=~age)))
  > identical(better.cc, fm1$call)
  [1] TRUE

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
>  > fm1$call$random
> list(Subject = ~age)
> 
> How is it possible to get the right call (similar to the one from 
> fm1$call) by means of call()?
> 
> thanks,
> vito
> 
> 
> 
> -- 
> ====================================
> Vito M.R. Muggeo
> Dip.to Sc Statist e Matem `Vianelli'
> Università di Palermo
> viale delle Scienze, edificio 13
> 90128 Palermo - ITALY
> tel: 091 23895240
> fax: 091 485726/485612
> http://dssm.unipa.it/vmuggeo
> 
> ______________________________________________
> 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.
> 



More information about the R-help mailing list