Running Scripts
In this page:
Running Scripts
An R script is run from the command line with Rscript filename.R, executing every statement top to bottom. This is the standard way to run non-interactive R code, such as in automation or batch jobs. The interactive console and Rscript behave almost identically except for automatic printing.
Note: Use Rscript for batch execution; use the interactive R console (or RStudio) for exploratory work.
Example: Running Scripts
# Run an R script from the command line
Rscript analysis.R
# Start the interactive R console
R
⚠️ Run this command in your terminal.
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: