[R] Writing to a file
arun
smartpink111 at yahoo.com
Wed May 22 03:46:10 CEST 2013
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".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.pdf
Type: application/pdf
Size: 4635 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130521/e52733e3/attachment.pdf>
More information about the R-help
mailing list