Running Entire R code
Or take a look at Rscript
for running R scripts from the command line. In addition, in Rstudio you can run the entire script by pressing Ctrl+Shift+Enter without selecting any code. In addition, there is a shortcut to source
the current script file (Ctrl+Shift+s), which runs the script without echoing each line.
Assuming your script is named "myScript.r", you can use something like source("myScript.r", echo = TRUE)
to run the entire script.