[R] nlme graphics in a loop problem
Chris Knight
christopher.knight at plant-sciences.oxford.ac.uk
Thu Jun 17 21:19:53 CEST 2004
Hi, I'm fitting mixed effects models using the lme function of the nlme
package. This involves using the various associated plot functions.
However, when I attempt to fit a number of models using an loop, whilst
the models work, the plot functions fail. As a trivial example, the
following works:
library(nlme)
graphics.off()
x<-c(1:10)
y<-c(1:4,7:12)
b<-as.factor(c(rep("A",5),rep("B",5)))
model<-lme(y~x, random=~1|b)
plot(model)
however the following, identical code in a loop, doesn't:
graphics.off()
for(i in 1:2){
x<-c(1:10)
y<-c(1:4,7:12)
b<-as.factor(c(rep("A",5),rep("B",5)))
model<-lme(y~x, random=~1|b)
plot(model)
}
Mostly this is only inconvenient, since a similar plot may be created
successfully within the loop using plot(fitted(model),resid(model)),
however, I'd be keen to find out whether this is a general problem/sign
of something deeper or I'm just missing something easy that could sort
it out.
Thanks,
Chris
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dr. Christopher Knight Tel:+44 1865 275111
Dept. Plant Sciences +44 1865 275790
South Parks Road
Oxford OX1 3RB Fax:+44 1865 275074
` · . , ,><(((º>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the R-help
mailing list