Alternatives to system() in R for calling sed, rsync, ssh etc.: Do functions exist, should I write my own, or am I missing the point?
does R already have built in commands for common shell programs, if so, where can I find them?
There are some function like grep
that mimic shell progams. Search for them as you would any other function – the names are often the same.
if not, are there reasons to avoid writing my own functions?
No obvious problems.
is there a better alternative to the approach outlined in the rsync example above?
Looks good, but you need to be very careful about checking user input if things are passed to the shell.
would a collection of such functions warrant a package?
Absolutely. Go for it.
There's not much out there, apparently ...
> library(sos)> findFn("rsync")found 0 matchesx has zero rows; nothing to display.Warning message:In findFn("rsync") : HIT not found in HTML; processing one page only.> findFn("ssh")found 27 matches; retrieving 2 pages2
The ssh
hits are either false positives or part of parallel-processing packages (GridR
, nws
, biopara
). RCurl
has an scp
command (based on libcurl
, not a system call).