在R中使用paste批量建立输出文件

  • paste
1
2
3
paste("result.", 1:6, sep="")
# output
"result.1" "result.2" "result.3" "result.4" "result.5" "result.6"
  • paste in for
1
2
3
4
5
6
7
8
for (n in 1:5){
file <- paste ("result_", n, ".pdf", sep="")
pdf(file)
......
dev.off()
}
# output
"result_1.pdf" "result_2.pdf" "result_3.pdf" "result_4.pdf" "result_5.pdf"