Message-ID: <4ED3EC0F.4030407@gmail.com>
Date: 2011-11-28T20:16:15Z
From: Duncan Murdoch
Subject: R CMD <custom>?
In-Reply-To: <CABdHhvGnCtK-D6QoiGUjBt0oygMZq_BTbqC_brqUAF7AnLu2tQ@mail.gmail.com>
On 28/11/2011 2:48 PM, Hadley Wickham wrote:
> It'd be cool if R CMD was user extensible through packages, so that (e.g.)
>
> R CMD mypackage::mycommand
>
> would do something like:
>
> path<- system.file("cmd", paste(command, ".r"), package = package)
> if (!file.exists(path)) {
> stop("Command ", command, " in ", package, " does not exist")
> } else {
> source(path)
> }
>
> And maybe `R CMD mypackage` would look in mypackcage/cmd/default.r.
>
That does seem to mix up namespaces quite a bit. But what does it get
you that "Rscript -e" doesn't already give you? You can set up your
package so that
R CMD mypackage::mycommand
executes a function, using delayedAssign or some of the more exotic
features (like external pointers and finalizers).
Duncan Murdoch