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@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.

Reply via email to