R R

R: Running Code & Tools

Running R

R script.R              # run a script (non-interactive)
R                       # start interactive REPL
R -e "print(1 + 1)"     # run inline expression
Rscript script.R        # alternative way to run scripts (better for automation)

RStudio (the standard IDE)

RStudio (now called Posit) is the standard IDE for R. It's free, open-source, and available on all platforms. Features: - Four-pane layout: script editor, console, environment/files, plots/help - Built-in data viewer for data frames - R Markdown integration for reproducible reports - Version control with Git built-in - Package management UI

Other editors

  • VS Code — install the R extension by REditorSupport for language support, debugging, and plot viewer
  • Jupyter — install the IRkernel package to use R in Jupyter notebooks
  • Emacs with ESS (Emacs Speaks Statistics) — powerful for experienced users

Package management

install.packages("ggplot2")      # install from CRAN
install.packages(c("dplyr", "tidyr"))  # multiple packages
library(ggplot2)                  # load a package
update.packages()                 # update all installed packages
remove.packages("ggplot2")       # uninstall
installed.packages()              # list installed packages

CRAN (Comprehensive R Archive Network)

CRAN is the official R package repository (like PyPI for Python or npm for JavaScript). It hosts over 20,000 packages. All packages on CRAN have been reviewed for quality and compatibility.

Installing R

  1. Download R from cran.r-project.org
  2. Install RStudio from posit.co
  3. Start RStudio and you're ready

Learning resources

Quick check below!