Re: [R] Problems with augPlot and for loops

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon, 25 Feb 2008 16:51:08 +0000 (GMT)

FAQ Q7.22 (you may not have been aware that you were using lattice).

On Mon, 25 Feb 2008, Nicola Buratti wrote:

> Dear all,
> I'm a new R user and I find myself in trouble with some of the plot
> functions.
> I'm trying to save a sequence of plots to eps files using a for loop, but I
> get only empty figures.
> In each iteration of the for loop I fit a nlme model and I'd like to plot
> its prediction of the dependent variable values.
> This is the code I'm using to plot the figures (I removed the commands I use
> to fit the model, but they are OK)
>
> postscript(file="saReg%03d.eps",onefile=FALSE)
> for (i in 1:length(names(DatasetSa))) {
> #[...]
> plot(augPred(DatasetGrp.fit,primary = ~R, level =
> 0:1),title=names(DatasetSa)[i])
> #[...]
> }
> dev.off()
>
> When I run this code I only get one empty figure even though the loop is
> executed 70 times. If I try to run the command
>
> plot(augPred(DatasetGrp.fit,primary = ~R, level =
> 0:1),title=names(DatasetSa)[i])
>
> outside the loop everything goes fine.
>
> I also tried to open and close a device in each loop iteration,
>
> for (i in 1:length(names(DatasetSa))) {
> #[...]
> fignam <- paste("SaReg",i,sep=".");
> fignam <- paste(fignam,".eps",sep="");
> postscript(file=fignam)
> tempData<-augPred(DatasetGrp.fit,primary = ~R, level = 0:1)
> plot(tempData)
> dev.off()
> #[...]
> }
>
> in that case I get the correct number of eps files but they are all empty.
>
> I would really appreciate you help.
>
> Thank you,
> NB
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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.
Received on Mon 25 Feb 2008 - 17:03:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Feb 2008 - 17:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive