If you wanted to execute your whole buffer - if you are in Unix/Linux, you can also start off your script with a shebang:
#!/usr/bin/Rscript
And make your file executable
chmod 744 myscript.r
(I recall reading Google likes their r scripts to end in .R but oh well...) and you can execute it this way:
./myscript.r
And, with arguments,
./myscript.r arg1 arg2
(which I have actually used to invoke an R function from a Matlab system call) and in your R file you might use
userargs = tail(commandArgs(),2)
to get arg1 and arg2. You can also do without the shebang:
R --no-save < myscript.r arg1 arg2
and so on. With Windows I recall it was
R CMD BATCH myscript.r
or something to that effect... I did notice a little delay when running commands through ESS (though I do love ESS dearly) so when I know I want to run the the whole buffer I sometimes start a shell in a window below the R script (where the R buffer would normally reside) and use the tricks above.
You can also use
echo 'source("myscript.r")' | R --no-save
as well - the benefit of using these methods over running 'source("myscript.r")' directly in R or an R buffer is that you are starting out with a clear workspace (though you should be careful that your .Rprofile will not be loaded unless you call 'source("~/.Rscript")' explicitly in 'myscript.r') so you can be sure that your script is self-contained (it calls the proper libraries, your lexically-scoped functions aren't referencing unintended variables in the global space that you forgot to remove, and so on).