8 Lists

8.1 Lists

Variables of the type list can contain elements of different types (including vectors and matrices), whereas elements of vectors are all of the same type.

## [[1]]
## [1] "Stefano"
## 
## [[2]]
## [1] 2015
## [1] "Stefano"

8.2 Named Lists

In named lists each element has a name, and elements can be selected to using their name after the symbol $.

## $name
## [1] "Stefano"
## 
## $start_year
## [1] 2015
## [1] "Stefano"

8.3 lapply

With lapply take care that the function makes sense for any element in the list

## [[1]]
## [1] FALSE
## 
## [[2]]
## [1] TRUE