Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
What are vectors?
4. Single-element vector
Vector operations
Indexing and filtering
Summary

Instruction

Great job! Have you noticed how R displayed a vector? It broke the long vector into multiple lines so you could see all values. Each line is preceded by the position of the element that happens to be at the beginning of the line. This position is denoted in brackets. You probably remember that R displays single values in the same way. That's because single values in R are vectors. If you create a variable named height:

height <- 172

R creates a one-element vector. This is why R displays [1] before the value, it means it's a vector.

[1] 172

You can create a one-element vector with the c() function as well:

height <- c(172)

This vector is the same as the one created with single-value assignment.

Exercise

We created a variable called company_id that stores Versico's company registration number. Type the vector name in your editor, and observe the result.