R code doesn't save plot image [duplicate]
问题 This question already has an answer here : ggplot's qplot does not execute on sourcing (1 answer) Closed 7 years ago . The following code produces an image: library(latticeExtra) x=runif(40) y=runif(40) z=runif(40) png(filename=paste(i,".png",sep="")) levelplot(z ~ x + y, panel = panel.levelplot.points, col.regions = rainbow(50)) dev.off() But the following code does not. Why? library(latticeExtra) for(i in seq(1,5)) { x=runif(40) y=runif(40) z=runif(40) png(filename=paste(i,".png",sep=""))