Tsallaka zuwa abun ciki
Justice Tech School

R Vectors

A vector holds values of one type. Create with c(). Index from 1. Useful: length, seq, rep, rev, sort, sum, mean, which.

Example
x <- c(5, 2, 9, 1)
print(x[1]); print(sort(x)); print(length(x))
print(seq(1, 10, by = 3)); print(rep("a", 3)); print(mean(x))

Exercise

First index in R.

x[]

Quiz Test

Where do R indexes start?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.