Introduction

Each variable is a vector

char_vec <- c("a", "first", "test")
num_vec <- c(1,2.5,4.7)
bool_vec <- c(T,F)

first_list <- list(char_vec, num_vec, bool_vec)
first_list
## [[1]]
## [1] "a"     "first" "test" 
## 
## [[2]]
## [1] 1.0 2.5 4.7
## 
## [[3]]
## [1]  TRUE FALSE

It is important to consider the double bracket figure, as this is identifying the vector, and the single bracket figure is referring to the element number of that vector

To access particular elements of a list:

first_list[1]
## [[1]]
## [1] "a"     "first" "test"
first_list[[2]]
## [1] 1.0 2.5 4.7
first_list[[3]][2]
## [1] FALSE

If you want to name certain parts of the list, you can assign these when constructing the list. The $ operator prior to each vector makes it easier to locate those particular vectors, and will be very handy when utilising dataframes

second_list <- list(chars = char_vec, nums = num_vec, bools = bool_vec)
second_list
## $chars
## [1] "a"     "first" "test" 
## 
## $nums
## [1] 1.0 2.5 4.7
## 
## $bools
## [1]  TRUE FALSE
second_list$chars
## [1] "a"     "first" "test"