I have two different plots. I want to put them together, I use them to save in pdf. However, the pdf can not open. I am using the following simple template to save the figures in pdf, can you please help me with that? Thanks.
for(i in 1:4){
par(mfrow=c(2, 1))
# plot 1
layout(matrix(c(rep(1,6),rep(2,4)),nrow=2,ncol=5))
plotModelFit(dataBlock,fit)
plotMarginal(extract(fit,"beta[1]"),predictor="dataset age",col="blue")
#plot 2
plotModelFit(dataBlock,fit)
plotMarginal(extract(fit,"beta[1]"),predictor="dataset age",col="blue")
# save to pdf
pdf(file=sprintf("/Users/test.pdf",responseVars[i]),width=10,height=6)
dev.off()
}
CodePudding user response:
you need only one of
par(mfrow=c(2, 1))
andlayout(matrix(c(rep(1,6),rep(2,4)),nrow=2,ncol=5))
.you need to place
pdf()
call beforepar()
orlayout()
.you need something like
sprintf("/Users/test-%s.pdf",responseVars[i])
for the file name.