I have a file, called a.r, it has a chmod of 755,
sayHello <- function(){
print(\'hello\')
}
sayHello()
Ho
This does not answer the question directly. But someone may end up here because they want to run a oneliner of R from the terminal. For example, if you just want to install some missing packages and quit, this oneliner can be very convenient. I use it a lot when I suddenly find out that I miss some packages, and I want to install them to where I want.
To install to the default location:
R -e 'install.packages(c("package1", "package2"))'
To install to a location that requires root privileges:
R -e 'install.packages(c("package1", "package2"), lib="/usr/local/lib/R/site-library")'