[R] R command execution from shell
murdoch.duncan at gmail.com
Tue Jan 4 21:36:36 CET 2011
On 04/01/2011 3:21 PM, Sebastien Bihorel wrote:
> Dear R-users,
> Is there a way I can ask R to execute the "write("hello
> world",file="hello.txt")" command directly from the UNIX shell, instead
> of having to save this command to a .R file and execute this file with R
> CMD BATCH?
Yes. Some versions of R support the -e option on the command line to
execute a particular command. It's not always easy to work out the
escapes so your shell passes all the quotes through... An alternative
is to echo the command into the shell, e.g.
echo 'cat("hello")' | R --slave
(where the outer ' ' are just for bash).
More information about the R-help