Functions defined by integrals
How to call R functions from command line and from within R shell
R < --vanilla mean.R
R CMD BATCH mean.R
If you are trying to run the file from inside the R shell, that's wrong way.
You should type