Skip to content
Justice Tech School

Indexing Vectors

Use positive indexes, negatives to drop, logical vectors and names.

Example
v <- c(a = 5, b = 8, c = 2)
print(v[1])
print(v[-1])
print(v[c(TRUE, FALSE, TRUE)])
print(v[v > 3])
print(v["b"])

Exercise

Drop the first.

v[1]

Quiz Test

What does v[-1] do?

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