Hi,
Try this:
lst1<-lapply(1:5,function(i) {pdf(paste0(i,".pdf"));
hist(rnorm(100),main=paste0("Histogram_",i));dev.off()}) #you can change the
numbers
A.K.
>I'm trying to generate a pdf called 1.pdf, 2.pdf, 3.pdf etc and it isn't
>working. My code is:
>x <- 0
>for(i in 1:1000){
>x <- x + 1
>pdf(as.character(x),".pdf") #writes out to pdf
>for(i in 1:1000000){
>hist(rnorm(1)) # graphs histogram, writen to the file
>}
>
>dev.off()
>}
>
>Also, I triedto just do
>a<- 1
>a
>between the pdf() and dev.off() line and it wouldnt add it to the file, even
with a name as "foo.pdf".
1.pdf
Description: Adobe PDF document
______________________________________________ [email protected] 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.

