Numeric Index Vector
A new vector can be sliced from a given vector with a numeric index vector, which consists of member positions of the original vector to be retrieved.
Here it shows how to retrieve a vector slice containing the second and third members of a given vector s.
Duplicate Indexes
The index vector allows duplicate values. Hence the following retrieves a member twice in one operation.
Out-of-Order Indexes
The index vector can even be out-of-order. Here is a vector slice with the order of first and second members reversed.
Range Index
To produce a vector slice between two indexes, we can use the colon operator ":". This can be convenient for situations involving large vectors.
More information for the colon operator is available in the R documentation.