R Tutorial

R Collections

Source: Bro Code

Lists, Arrays & Collections

Collections let you store multiple values in one variable. Loops, filters, and maps operate on collections in every R program.

  • Ordered lists — arrays, lists, vectors
  • Key-value maps — objects, dictionaries, hashes
  • Immutable vs mutable collections
  • Iteration with for loops and higher-order methods
R
// Collections in r
  1. Choose the right structure — array for ordered data, map for lookups
  2. Prefer built-in methods over manual index loops when available
  3. Watch for off-by-one errors in index-based loops