John, The first thing I would do is create a simpler example, i.e., to help isolate the issue. Heres a simple example:
The contents of a file are: -------------------------------------------- #! /usr/bin/Rscript pdf('test1.pdf') plot(1:10) dev.off() pdf('test2.pdf') plot(10:1) dev.off() ---------------------------------------------- With this file, I get both pdf files either way. Since youre using plotting functions from ggplot2, you may need to wrap print() around the qplot() call in the second one. That is, print( qplot(fitted(profiles.spl), residuals(profiles.spl)) ) The null device message is what dev.off() returns, as in this example: > x11() > dev.off() null device 1 So its not relevant. However, with my simple example above, I get the null device message twice when I run it as an Rscript. Whats the first line of your file look like? Try including the -- restore option, if you have not already: #! /usr/bin/Rscript restore Your .RData file is not automatically loaded with Rscript, and the plot that isnt happening may depend on some object that is loaded from .RData. Although, in that case, I would expect an error message. -Don On 1/20/11 6:53 PM, "John Helly" <hel...@ucsd.edu> wrote: Hi. I'm running R OS X GUI 1.35-dev Leopard build 64-bit. When I run the following code (snippet from a larger code) from the GUI I obtain 2 separate *.pdf files as you would expect from the high-lighted code. However, when I run from Rscript (command-line), I only get the first one. No errors appear in the console log however I do get a 'null device' message that I don't understand. It's probably related but I have no clue how to debug this. Perhaps the second output file is not getting initialized? I've tried a few variations to see if I can unearth the cause but no joy so far. Any suggestions would be appreciated. Thanks. ... profiles.spl <- smooth.spline(x, y) (profiles.spl) x_pred = seq(1,as.integer(max(x))) B = data.frame(predict(profiles.spl,x_pred)) pdf(file=paste("/Volumes/SLR_Data_001/USN_SERDP_SLR/data/level1/beach_profiles_Flick/",Filename,".pdf",sep="")) caption = paste(aLocation," (", aYear,".",aMonth,".",aDay,")",sep="") credits = paste("splineWriter.R / hel...@ucsd.edu / 20110120") xrng = range(x) yrng = range(y) pred = qplot(x,y, data=B, xlab="Distance (m)", ylab = "Elevation (m)", xlim=c(0,1000), ylim=c(-12,4)) pred + geom_text(aes(700,2,label=caption)) + geom_text(aes(180,-12,label=credits),size=2.7) dev.off() ## Residual (Tukey Anscombe) plot: pdf(file=paste("/Volumes/SLR_Data_001/USN_SERDP_SLR/data/level1/beach_profiles_Flick/",Filename,"TA.pdf",sep="")) qplot(fitted(profiles.spl), residuals(profiles.spl)) dev.off() ... -------------- John Helly, University of California, San Diego / San Diego Supercomputer Center / Scripps Institution of Oceanography / stonesteps (Skype) / stonesteps7 (iChat) / http://www.sdsc.edu/~hellyj [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory 925 423-1062 [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.