Sunday, 18 August 2013

Run R script from command line

Run R script from command line

I have a file, called a.r, it has a chmod of 755,
sayHello <- function(){
print('hello');
}
sayHello();
I am trying to call it from the command line,
./a.r
It gives me the following error,
./a.r: line 1: syntax error near unexpected token `('
./a.r: line 1: `sayHello <- function(){'
R CMD BASH a.r didn't work either. Error: /usr/lib/R/bin/Rcmd: 62: exec:
BASH: not found
What is wrong?

No comments:

Post a Comment