You should be able to do all this within R.>From what you have written I don't see a compelling reason to use scriptsat the shell level. Best, Eric On Wed, Jul 25, 2018 at 9:41 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Wed, 25 Jul 2018, Eric Berger wrote: > > 1. For R scripts you should also consider the package littler developed by >> Dirk Eddelbuettel, Highly recommended. For info >> http://dirk.eddelbuettel.com/code/littler.html or the github repository. >> > > Eric, > > I'll definintely look at that package. > > 2. Scripts can be useful both for short calculations, extending the shell, >> or for large R jobs that are not interactive and can run unsupervised. >> e.g. I have a script that is run automatically on a daily schedule. It >> performs a number of calculations and updates a database with the results. >> > > My immediate need is to import 30 data files, change factors into dates > and datetimes, print a summary, then plot a PDF scatterplot. This is why I > need to learn Rscript. I should be able to wrap that in a bash shell > script's for ... do loop that runs the Rscript for all *.dat files in the > directory. > > Much appreciated, > > > Rich > > ______________________________________________ > R-help at 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]]
On Wed, 25 Jul 2018, Eric Berger wrote:> You should be able to do all this within R. From what you have written I > don't see a compelling reason to use scripts at the shell level.Eric, The source() help page's last example calls a set of scripts to run sequentially. I assume this is used to run the same .R script on each file, with any file-specific variables used in each one. Perhaps I'm not seeing how to pass parameters to the script call with source() so that the same .R script can be automagically run for each imput file name. In my newness to this it appears Rscript allows running the same script substituting inpu file names based on arguments on the Rscript command line. Regards, Rich
Eric may have more to say, but the straightforward answer is: use functions to do what you want and pass any file specific info to them as parameters of function calls. If this seems arcane to you, then you have some homework to do, as using functions is a (maybe the) central programming paradigm in R. Numerous tutorials elaborate on this. If I have misunderstood, my apologies, and just disregard. 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 1:02 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> On Wed, 25 Jul 2018, Eric Berger wrote: > > You should be able to do all this within R. From what you have written I >> don't see a compelling reason to use scripts at the shell level. >> > > Eric, > > The source() help page's last example calls a set of scripts to run > sequentially. I assume this is used to run the same .R script on each file, > with any file-specific variables used in each one. Perhaps I'm not seeing > how to pass parameters to the script call with source() so that the same .R > script can be automagically run for each imput file name. In my newness to > this it appears Rscript allows running the same script substituting inpu > file names based on arguments on the Rscript command line. > > Regards, > > Rich > > ______________________________________________ > R-help at 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]]