You can run R script in following ways:
cliffgao
(1) open R console and type:
source("my.code.R“)
(2) in command line or in bash:
add
"#!/usr/bin/env Rscript"
in the first line of "my.code.R"
$ Rscript my.code.R
or
chmod +x my.code.R
./my.code.R
(3) in BATCH mode
$ R CMD BATCH my.code.R
(4) See more in
https://manuals.bioinformatics.ucr.edu/home/programming-in-r