[R] lme plot

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Mar 24 17:07:15 CET 2006

Dieter Menne <dieter.menne at menne-biomed.de> writes:

> getData returns non-null).  The lines I don't understand in plot.lme are 
>             alist <- lapply(as.list(allV), as.name)
>             names(alist) <- allV
> # next line
>             alist <- c(as.list(as.name("data.frame")), alist)
>             mode(alist) <- "call"
>             data <- eval(alist, sys.parent(1))
> This code turn up again and again in nlme, but I admit I don't understand what 
> it means.
> Anybody taking the challenge to dissect it?

Shouldn't be too hard:

allV is a vector of variable names (character vector)
first turn it into a list of R names (a.k.a. symbols)
then add names to the list identical to the original data
stick the symbol data.frame at the beginning and convert to call

This has the net effect that you generate a function call like

  data.frame(age=age, sex=sex, beauty=beauty)

finally, you evaluate that call in the parent frame, in which
presumably age, sex, and beauty will be defined,

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

More information about the R-help mailing list