Running Entire R code

alphabeta picture alphabeta · Oct 7, 2012 · Viewed 36.3k times · Source

How do I run an entire R code script in RStudio?

When I click on the Run button in RStudio, the code runs only on a line-by-line basis and I want it to execute all the code at once instead of running through line by line.

So far the only method I've tried that works is selecting the entire script and then clicking the run button. The other option is running line by line.

Is there an easier way to run the entire script with a single button or a shortcut?

Answer

Paul Hiemstra picture Paul Hiemstra · Oct 7, 2012

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.