'For loop to write pdf in R
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?
Solution 1:[1]
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() }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nad Pat |
