Back to my favourite R subject: batch mode. Some months ago, I pointed out how the default of saving .RData automatically in batch can often lead to completely erroneous results when using data.frames. Basically the idea of .RData is to save the environment to start where one left off. This will generally be quite different than where one started the session. The idea of a batch file is to redo a session and create hard copy of it. Hence one wants to start at the beginning, not the end. So a .RData file must absolutely not be present. The same holds if you run a batch file twice. The first time it must not create an .RData. Otherwise, completely wrong results can be produced the second time. Martin suggested a work around by having a final line in each file that tests for interactive. This is fine if you remember to put it in all files. Here is an example of a further problem that hit me the other day. I am developing some new libraries containing C code. At a certain point, I wanted hard copy, from batch, before changing the C to compare before and after. My file has a library call in it (but I forgot the test on the last line). I ran the batch then went back to interactive. When I loaded the library and tried to run the C code, it said that it was not in the load table. Because I was debugging, it took me quite awhile to discover that the problem was the .RData created behind my back. When is the default going to be changed to not saving the .RData in batch mode???? Does anyone use batch mode except me? Jim =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Martin Maechler
1997-Nov-12 09:48 UTC
R-alpha: batch -- no problem with make and proper Makefile
Yes, I use batch too. In addition, I also use 'make' consistently My current approach (this is Makefile syntax) Just @-rm -f .RData R < input > output Actually, I'm a bit smarter and have a Makefile of the form ##--------------------- Makefile for different R batch jobs ---------- ##----------------------------- Martin Maechler ---------------------- R = /usr/local/bin/R R = /usr/local/bin/R-MM TESTsrc = str-test.R foobar.R thistest.R thattest.R TESTout = $(TESTsrc:.R=.Rout) %.Rout: %.R if [ -f .RData ]; then mv .RData .RData-mm; fi if [ -f .Rprofile ];then mv .Rprofile .Rprofile-mm; fi touch .Rprofile; (echo '##-*- R-transcript -*- --- empty .Rprofile'; $(R) < $< ) > $@ -@wc $@ all: tests tests: $(TESTout) str-test.Rout:: str-src.R clean: ; mv $(TESTout) out-safe/ ; rm -f $(Shars) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Jim Lindsey <jlindsey@luc.ac.be> writes:> When is the default going to be changed to not saving the .RData in > batch mode???? Does anyone use batch mode except me?One rather nasty thing to consider is that interactivity is (as I understand it) detectable only by the existence of a controlling terminal. This can cause trouble with cases where the controlling terminal disappears, one case being upon logout from the windows system or a system shutdown. Presumably, most people prefer their work to be saved in those cases. What might be a much better idea is to make the saving (and loading too) of .Rdata into command line options, so that R BATCH filein fileout would translate into R -nosaveimg -noloadimg < filein > fileout -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
There absolutely has to be a global option (environment or RProfile) that allows creating the .RData in batch mode to be disabled. It is not at all serious to expect that it be disabled in each batch file. (On my complete system, I have creation of .RData in interactive mode disabled by redefinition of q() in the global RProfile.) Otherwise, R will never be a serious tool for statistical work because of the incorrect statistical analyses that stray unnoticed .RData files can produce. If this control of options is not introduced into 0.60, I shall have seriously reconsider whether I shall continue using R. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
In my limited knowledge of computers, a program that creates a hidden file without informing you and then, in subsequent runs, has its behaviour modified in unpredictable ways because of this is called a virus. I am glad to learn that, with Ross's suggestion, R will finally be removed from this undesirable class of programs, something that I have been requesting since v0.13. I strongly recommend that the default in the distribution be no .RData so the beginners do not get badly burned. The warnings in the R notes about cleaning up before creating the .RData are far from sufficient to indicate the dangers of these files. There should also be a clear statement in the FAQ about the problems with their existence. Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._