Introduction to lists

A named, nested list.

otherlist <- list(
  mango = 100, 
  nice = list(sweet = TRUE, dirty = FALSE)
)
otherlist
## $mango
## [1] 100
## 
## $nice
## $nice$sweet
## [1] TRUE
## 
## $nice$dirty
## [1] FALSE
str(otherlist)
## List of 2
##  $ mango: num 100
##  $ nice :List of 2
##   ..$ sweet: logi TRUE
##   ..$ dirty: logi FALSE
# element extraction:
otherlist$nice # one level deeper
## $sweet
## [1] TRUE
## 
## $dirty
## [1] FALSE
otherlist[[2]] # one level deeper
## $sweet
## [1] TRUE
## 
## $dirty
## [1] FALSE
otherlist$nice$sweet # two levels deeper
## [1] TRUE
otherlist[[2]][[1]] # two levels deeper
## [1] TRUE