Export multiple glm graphs as PNG?

SO

I am trying to export graphs of my linear model. When I do this as a PDF, the PDF has four pages and four different graphics. When I export PNG, I get only the first graph. How can I export to get all four graphics as separate PNG files?

What worked with PDF:

lrfitX11SUMS <- glm(X11SUMS ~ POLITA + CIRCULATION + COMPAPER + TrafficRankUS, data=NewspTest)

    summary(lrfitOTONE)
    pdf("/Users/william/Desktop/output/lmfitOTONE1.pdf")
    plot(lrfitOTONE)
    dev.off()

What DOES NOT WORK with PNG (and spent two hours searching on the Internet and in the plot documentation to no avail):

lrfitX11SUMS <- glm(X11SUMS ~ POLITA + CIRCULATION + COMPAPER + TrafficRankUS, data=NewspTest)

summary(lrfitOTONE)
png("/Users/william/Desktop/output/lmfitOTONE1.png", width=720, height=720, pointsize=16)
png("/Users/william/Desktop/output/lmfitOTONE2.png", width=720, height=720, pointsize=16)
png("/Users/william/Desktop/output/lmfitOTONE3.png", width=720, height=720, pointsize=16)
png("/Users/william/Desktop/output/lmfitOTONE4.png", width=720, height=720, pointsize=16)
plot(lrfitOTONE)
dev.off()

How to get my images?

Thank,

-wm

+5
source share
2 answers

PDF . PNG . ?png filename ?postscript .

- :

png("/Users/william/Desktop/output/lmfitOTONE%1d.png", width=720, 
    height=720, pointsize=16)
plot(lrfitOTONE)
dev.off()

%1d , 1- , , . 4 png() , , .

+8

- :

setwd("/Users/william/Desktop/output/")
tmpf <- function(i) {
   png(paste("lmfitOTONE",i,".png",sep=""), width=720, height=720, pointsize=16)
}
wplot <- c(1,2,3,5) ## see ?plot.lm for definition of 'which'
for (i in seq_along(wplot)) {
   tmpf(i); plot(lrfitOTONE, which=wplot[i]); dev.off()
}

, plot.lm ( , plot, glm, glm lm ) which, which wplot . , : , .

+6

All Articles