Brandon Bertelsen Brandon Bertelsen - 3 months ago 10
R Question

How to run script contained in a package from shell

Is there an elegant way to run a script contained in an installed package from the command line, with arguments.

So, I'm aware that we could do something like:

Rscript path/package/scritpts/script.R arg1 arg2 arg3


But I'd like something that's more elegant. Because
path/package
can be ridiculous sometimes.

Answer

Dirk has provided a viable solution by way of his littler package:

Rscript $(R -e 'cat(system.file("scripts","file.R",package = "pkg"))') arg1 arg2 arg3  
Comments