To run an R script file directly from the UNIX command line, and print the output to the terminal, use the following command:
Rscript q.R
Note: The Rscript by default does not load the methods function. To load the methods function if your code relies on it, please load it explicitly on your script.
If you want to learn more about R programming watch this tutorial on Introduction to Data Science with R