Every operation in R is a function call. For example, when you subset a vector using []
, you’re really calling the function [
.
This allows us to easily subset the elements of a list when the elements are vectors. For example, given a list of 3 elements: a character vector, an integer vector, and a logical vector, we can use lapply
and [
to easily extract the 2nd value from each vector.