2. Vectors

Learn R vectors, indexing, and vectorized arithmetic with live, editable R code.

A vector is Rโ€™s basic building block โ€” an ordered collection of values of the same type, made with c(). Arithmetic on vectors happens element-by-element. Indexing uses square brackets and starts at 1, not 0.

Back to top