Angelo Secchi wrote: > > On Wed, 09 Nov 2005 12:25:37 -0000 (GMT) > (Ted Harding) <[EMAIL PROTECTED]> wrote: > > >>On 09-Nov-05 Roger Bivand wrote: >> >>>On Wed, 9 Nov 2005, Angelo Secchi wrote: >>> >>>>Hi, >>>>I wrote a small R script (delta.R) using commandArgs(). The script >>>>works from the shell in usual way >>>> >>>>R --no-save arg1 < delta2.R >>>> >>>>Suppose arg1 is the output of another shell command (e.g. gawk, >>>>sed ...). Is there a way to tell R to read arg1 from the >>>>output of the previous command? Any other workaround? >>> >>>Use shell variables, possibly also Sys.getenv() within R as well as or >>>instead of commandArgs(). >> >>If it's a fairly simple shell comand (and even if it isn't, though >>it could get tricky for complicated ones) you can use the "backquote" >>trick (called, in well-spoken circles, "command substitution"): >> >> R --no-save `shellcmd` < delta2.R >> >>As in all shell command lines, wherever you have a command (including >>arguments etc.) between backquotes, as exemplified by "`shellcmd`" above, >>the output of the command (as sent to stdout) replaces "`shellcmd`" in >>the command-line. This could be a lot of stuff (depending on what >>"shellcmd" is), or just one value, or whatever.
... and this behaviour is OS (or at least command shell specific) for anyone trying this on Windows and wondering why it doesn't work. ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html