Just move your pdf()
function call and your dev.off()
call outside the loop:
somePDFPath = "C:\\temp\\some.pdf"
pdf(file=somePDFPath)
for (i in seq(5,10))
{
par(mfrow = c(2,1))
VAR1=rnorm(i)
VAR2=rnorm(i)
plot(VAR1,VAR2)
}
dev.off()
Note my use the the seq()
function to loop instead of while()
with a counter variable.