From murdoch.duncan at gmail.com  Mon Nov 28 21:16:15 2011
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Mon, 28 Nov 2011 15:16:15 -0500
Subject: [Rd] R CMD <custom>?
In-Reply-To: <CABdHhvGnCtK-D6QoiGUjBt0oygMZq_BTbqC_brqUAF7AnLu2tQ@mail.gmail.com>
References: <CAFDcVCSuR6159QO=0J8Xe9icY9AOLDnSUvMF=w7=r5+jaL=uZg@mail.gmail.com>
	<CABdHhvGnCtK-D6QoiGUjBt0oygMZq_BTbqC_brqUAF7AnLu2tQ@mail.gmail.com>
Message-ID: <4ED3EC0F.4030407@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



[Rd] R CMD <custom>?
Duncan Murdoch