Data Stucture: Vector
Tip 1. Creating Vectors
Tip 2. Basic Arithmetic on Vectors:
Tip 3. Accessing Elements:
Given the vector months <- c("Jan", "Feb", "Mar", "Apr", "May")
, retrieve the third element. Try accessing multiple elements by extracting the first, third, and fifth elements.
Tip 4. Vector Length:
Tip 5. Logical Indexing:
Tip 6. Combining Vectors:
Tip 7. Sorting Vectors:
Tip 8. Applying Functions:
Tip 9. Removing Elements:
Tip 10. Vector Recycling:
Use the vector x <- c(2, 4, 6)
and another vector y <- c(1, 2)
. Add x
and y
together to see how R handles vector recycling. Explain the result.