Selecting multiple elements with [

  • using vector of element names (1/3)

Vector example:

x <- c(apple = 10, banana = 20, melon = 30)
x
##  apple banana  melon 
##     10     20     30
x[c("melon", "apple")]
## melon apple 
##    30    10