Introduction to lists

If multiple elements are provided to c(), it tries to flatten them to one level:

  • usually creates a vector
  • creates a flat list if one element is a list (can be hierarchical) and another isn’t
c(mango = 100, nice = list(sweet = TRUE, dirty = FALSE))
## $mango
## [1] 100
## 
## $nice.sweet
## [1] TRUE
## 
## $nice.dirty
## [1] FALSE
c("a", list(TRUE, FALSE))
## [[1]]
## [1] "a"
## 
## [[2]]
## [1] TRUE
## 
## [[3]]
## [1] FALSE