← Back to R Course | Chapter 1: Getting Started | Lesson 3 of 6

Running Scripts

In this page:

  1. Running Scripts

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

bash
# 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:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.