Analyzing Statistics with GNU R
Date:   2005-11-26 09:19:40
From:   kfarnham

A member of the R mailing list suggests using the statement when writing R graphics to a file (see the "Saving Your R Work" section). The statement closes R graphics devices.

While the q() statement does close the output graphics file (because R by default flushes buffers and closes open files as it shuts down), the proper way to close the file is to apply the statement.

For example, the script that writes a PNG file of the S&P500 graph should be modified to be:

dv <- read.table("./SP500.txt", header=FALSE)
plot(dv[,2], type="l")