Re: [R] Device problems in a loop.

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 28 Mar 2008 15:12:52 +0000 (GMT)

This is an instance of FAQ Q7.22: you haven't plotted anything and so the device is not yet open.

On Fri, 28 Mar 2008, Todd Remund wrote:

>
> I have tried the following code to plot and save many box plots in files. The code works by itself, but does not run in a loop. The error indicates that there is no device. The error is printed below the code.
>
> Code:
>
> for(i in 1:len)
> {
> A = as.numeric(delta[Delta[i,1]])
> B = as.numeric(delta[Delta[i,2]])
> C = as.numeric(delta[Delta[i,3]])
> D = as.numeric(delta[Delta[i,4]])
> data <- scan(filenames52[i], quiet=TRUE)
> data <- matrix(data, ncol=8)
> grp <- c('K1','K2','K3','K4','N','NBC','NE','NEBC')
> grp <- as.factor(rep(grp, each=200))
> bwplot(c(data)~grp, ylab='MSE', pch=19,
> par.settings = list(plot.symbol = list(pch = "+")),
> main=eval(substitute(expression(paste(' ', delta[phi[1]],
> " = ", tval, ' | ',
> delta[phi[2]], ' = ', tval2, ' | ',
> delta[theta[1]], ' = ', tval3, ' | ',
> delta[theta[2]], ' = ', tval4,)),
> list(tval=A, tval2=B, tval3=C, tval4=D))))
>
> dev.print(file=filenameplot[i], device=png, width=600, height=480)
> dev.off()
> }
>
> Error is:
>
> Error in dev.print(file = filenameplot[i], device = png, width = 600, :
> no device to print from
>
> I cannot figure out why the loop won't work but setting i <- 1 or 2 ...
> and then running the code inside the loop will work. Does anyone have
> any suggestions.
>
>
>
>
> [[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 Fri 28 Mar 2008 - 15:16:08 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 Fri 28 Mar 2008 - 15:30:25 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