2.6) Useful Functions for Vectors
Try out the functions listed below on individual columns of the data frame GRASS
.
sort() |
sorts a vector into ascending order. |
rev() |
reverses the order of a vector. |
unique() |
gives the unique elements of a vector. |
rank() |
gives the ranks of the values in a vector. |
cbind() |
binds vectors together as columns of a matrix, so long as the vectors are of the same mode and equal length. Similarly, |
rbind() |
binds vectors as rows of a matrix. |
which() |
tells you which element/s of a logical vector are TRUE . You can put a logical test in the brackets in order to locate values that meet a criterion – e.g. which(y > 1.96) . |
We'll look at that last function in more detail on the next page...