[R] Calling library functions from outside R
Dirk Eddelbuettel
edd at debian.org
Thu Jun 18 20:23:07 CEST 2009
On 18 June 2009 at 14:02, Jim Nemesh wrote:
| Actually, I'm going to take by my comments.
|
| You can use Rscript with multiple -e arguments to do what I was
| looking for:
|
| Rscript -e 'library(broadgap.hapmaptools)' -e 'processAllFiles(dir="/
| humgen/cnp04/sandbox/steve/1m/hapmap3/genotypes/ftp.hapmap.org/genotypes/2008-07_phaseIII/hapmap_format/forward
| ", outRootDir="/humgen/cnp04/sandbox/data/snpTagging")'
That file structure reveals that you use a Unix-alike operating system, in
which case you should look at littler (which Gabor already pointed you too).
I use it all the time for scripted wrappers like your case here. E.g. and
obviously untested:
$ r -lbroadgap.hapmaptools,getopt \ # this loads you both libraries, silently
-e'processAllFiles(dir="/humgen/.../forward", outRootDir="/humgen/.../snpTagging")'
where I truncated the paths and indented a line. [ In tis case we don't even
need getopt, do we ? ]
As a bonus, r starts up faster than Rscript [1]. And it may save you from
pressing six more keys not counting Shift.
Hope this helps, Dirk
[1] As it embeds R rather than calls it using exec() -- at the cost of not
being portable beyond Linux and OS X.
--
Three out of two people have difficulties with fractions.
More information about the R-help
mailing list