开发者

Call R function in Linux command line

开发者 https://www.devze.com 2023-03-20 05:44 出处:网络
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 param

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消