Nicely done! What if we would like to or use only one specific element of a vector? Let's take a look at how this can be done.
The first element of the vector
a <- c(8, 9, 10) can be accessed like this:
a is a vector. Inside the square brackets, we specify the index position (1) of the element we would like to retrieve. R will respond by printing the value of the first element in vector
a. Likewise, we can access the second element by using an index of 2, like so:
Note that some programming languages use 0 as the index position of the first element in a vector. However, R uses the index position 1 to reference the first element of a vector.