Asis Hallab
2013-Feb-13 04:09 UTC
[R] Is there a place to put executable R scripts in new packages?
Dear R users, writing an R package I wonder, if there is a place to put executable R scripts into. So that when the package is installed one can use the script from the command line. Say we have e new package called FunkyR and wanted to deliver with it an executable called FunkyCold.R, so that from the command line, one could do the following: Rscript FunkyCold.R argument_1 argument_2 Any hints or suggestions? Kind regards!
Duncan Murdoch
2013-Feb-13 10:28 UTC
[R] Is there a place to put executable R scripts in new packages?
On 13-02-12 11:09 PM, Asis Hallab wrote:> Dear R users, > > writing an R package I wonder, if there is a place to put executable R > scripts into. So that when the package is installed one can use the > script from the command line. > > Say we have e new package called FunkyR and wanted to deliver with it > an executable called FunkyCold.R, so that from the command line, one > could do the following: > > Rscript FunkyCold.R argument_1 argument_2 > > Any hints or suggestions?It's probably possible to achieve what you're asking for, but it would be messy and ugly. A better approach is to write a function corresponding to each script, then call it as Rscript -e "mypkg::FunkyCold(arg1, arg2)" Duncan Murdoch
Greg Snow
2013-Feb-14 04:15 UTC
[R] Is there a place to put executable R scripts in new packages?
See ?commandArgs for a way to access the arguments on the command line. With that you can write the FunkyCold.R script to grab the command line arguments and run the proper function (after loading your package). If you give more detail on what you want to accomplish we may be able to give more help. Also look at ?Startup for details of what happens when R starts, I have used this information to create desktop icons for clients (in windows) so that they double click on the icon and a particular function runs inside of R. On Tue, Feb 12, 2013 at 9:09 PM, Asis Hallab <asis.hallab@gmail.com> wrote:> Dear R users, > > writing an R package I wonder, if there is a place to put executable R > scripts into. So that when the package is installed one can use the > script from the command line. > > Say we have e new package called FunkyR and wanted to deliver with it > an executable called FunkyCold.R, so that from the command line, one > could do the following: > > Rscript FunkyCold.R argument_1 argument_2 > > Any hints or suggestions? > > Kind regards! > > ______________________________________________ > 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. >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]