R Cheat Sheet

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

The reference material consulted while preparing these pages is listed in the section bibliography.

A single-page, colour-coded summary of R, written against R 4.6.1 (released 2026-06-24) and checked on 2026-10-22, when R 4.6.2 was at release-candidate stage and scheduled for 2026-10-29 — the tool map (R, Rscript, R CMD build/check/INSTALL, RStudio and Positron), getting help and the startup files, syntax (<-, <<-, backticks, raw strings, |> with the _ placeholder, \(x)), the six atomic types with their literals, the coercion order and the special values (NA, NULL, NaN, Inf), vectors and recycling with %in%, %notin% and %||%, a subsetting grid for [, [[, $ and @, factors, matrices, lists and data frames, control flow, functions (argument matching, ..., match.arg(), on.exit(), closures, replacement functions), environments and lazy evaluation, the apply family, strings, regular expressions and dates, S3, S4, Reference Classes, R6 and S7 side by side, conditions and debugging, metaprogramming and formulas, I/O with files, connections, RDS, JSON, DBI and httr2, distributions, tests, models and graphics, tidyverse and data.table one-liners, packages, renv, roxygen2 and testthat, performance and parallelism, and a strip of what changed from R 4.0 to R 4.6 — handy for quick memorization or as a downloadable PDF desk reference.

For the full explanation, every option, and additional examples, see the dedicated pages:

Start here — R Reference.

Data manipulation ecosystems — The tidyverse and dplyr, tidyr, purrr and stringr and data.table.

References