Home > OS >  For loop to write pdf in R
For loop to write pdf in R

Time:03-21

I would like to create a R code which writes me 50 times a pdf but adjusts the name of the pdf fromy mypdf1.pdf to mypdf50.pdf. Is this possible using a for loop?

CodePudding user response:

It is indeed possible. Here is some simple code to create 50 blank PDF's names according to the specified using paste0. And you can then fill the PDFs with what ever in the loop, or create additional loops

 setwd()
 
 for (i in 1:50) {    pdf(paste0("mypdf", i, ".pdf"))
   
    dev.off() }
  • Related