Selecting multiple elements with [
- using vector of element names (2/3)
List example:
x <- list(apple = c(10, 15), banana = c(20, 25), melon = c(30, 35))
str(x)
## List of 3
## $ apple : num [1:2] 10 15
## $ banana: num [1:2] 20 25
## $ melon : num [1:2] 30 35
x[c("melon", "apple")] |> str()
## List of 2
## $ melon: num [1:2] 30 35
## $ apple: num [1:2] 10 15