[Rd] R CMD <custom>?

Duncan Murdoch murdoch.duncan at gmail.com
Mon Nov 28 21:16:15 CET 2011


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



More information about the R-devel mailing list