I am plotting several graphics in R in a loop and export them as a postscript using postscript()
.
for(i in 1:length(ind)){
postscript(names(ind[i]))
par(mar=c(6,8,6,5))
plot(ind[[i]][,c('YEAR','VALUE')],
type='b',
main=ind[[i]][1,'NAME'],
xlab="Time [Years]",
ylab="Value [mm]")
dev.off()
}
This works all fine but when I have a look at the files in Finder no file extension (e.g .ps) is written to them (I am on Mac OS X 10.8.5). As I want to further process and convert the output images with ImageMagick's mogrify
I rely on the file extension. Does anyone have a solution for that? When only plotting one file with postscript() then you specify the filename and the extension but how could this be done in a loop?
Another question: is it possible to incorporate command line tools such as mogrify (http://www.imagemagick.org/script/mogrify.php) into R so that it could be executed from there (a Windows AND Mac solution would be best)?
You could add an extension by paste(names(ind[i]), ".ps", sep = "")
. If you want to use command line tools, use shell
or system
.