"Within R one can use source() to run a batch file of R commands, while R CMD BATCH and Rscript are run from the command line. Is this correct?"
Yes. I think your query answers your query: You use Rscript when you want to use R in the command environment, perhaps as part of an analytical pipeline; and you source an R file when you want to work within R. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Jul 25, 2018 at 7:41 AM, Rich Shepard <rshep...@appl-ecosys.com> wrote: > Within R one can use source() to run a batch file of R commands, while R > CMD BATCH > and Rscript are run from the command line. Is this correct? > > Given these choices, when would I want to run a script within R using > source(), and when would it be better for me to run it from the command > line? > > Reading Appendix B.4 Scripting with R in R-info.pdf, ?Rscipt, and ?BATCH > I > get the impression that 'R CMD BATCH' reads from a named file and writes > output to a named file and Rscript reads/writes to stdin/stdout using > redirection. What are the pros and cons of each? When (or why) would I > select one over the other? > > TIA, > > Rich > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posti > ng-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.