Is there a way to directly call R functions from Linux command line without going into R environment? It doesn't work for me by just r开发者_如何学Gounning a R file, since I need to specify the parameters of the function every time I run it.
A simple built-in is the following BASH commands:
export NUM=10
R -q -e "rnorm($NUM)"
Yes, there is -- littler was written for exactly that purpose.
R itself added Rscript shortly thereafter, but as one of the two dudes behind littler I still like it better.
If your program is going to work on a single dataset, then simple-r might be the solution:
http://code.google.com/p/simple-r/
It is especially designed for simple statistical analysis as a part of Linux command line.
精彩评论