juniorR

How does indexing work in R?

Updated May 24, 2026

Short answer

Indexing in R is used to access elements using [] or [[]].

Deep explanation

R supports numeric, logical, and name-based indexing.

Real-world example

Extracting specific rows from a dataset.

Common mistakes

  • Confusing [] with [[]].

Follow-up questions

  • When to use [[]]?
  • What is logical indexing?

More R interview questions

View all →