[R] jpeg() creating empty files with qplot() in a loop

hadley wickham h.wickham at gmail.com
Fri Feb 22 00:28:28 CET 2008


>  So what could be the difference between the last example and it running
>  in a loop, that the former generates a proper jpeg file and the lattter
>  does not?
>
>  Does something more special than dev.off() need to be done with qplot
>  output when in a loop?

As well as Henrik's advice, you could also try using ggsave:


for (step in 1:length(steps)) {
 qplot(x, y, data=steps[[step]], geom="tile", fill=rgb(V1,V2,V3)) +
scale_fill_identity() + opts(aspect.ratio = .75)
 ggsave(file=paste("frame_",sprintf("%05d",step),".jpg",sep=""))
}

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list