The most flexible of structures
Discuss with a neighbor
Which of the following four objects are the same?
01:30
Discuss with a neighbor
Which of the following four objects are the same?
By atomic we mean:
A list is a non-atomic vector that can contain:
Created with list().
[][] extracts elements of a vector (atomic or non-atomic) using a subsetting (atomic) vector.
[][] extracts elements of a vector (atomic or non-atomic) using a subsetting (atomic) vector.
$Ape
[1] 1 2 3
$Boy
[1] "a"
$Cat
[1] 4 5 6
But what if you want the actual data structure inside the list?
[[]][[i]] Extracts original object inside the list.
To tell [] and [[]] apart, let’s use a metaphor of a train.
Draw the appropriate train or car for each of the following
x[1:2]x[[3]]x[-2]x[c(1, 1)]c(x[[3]], x[[1]])02:30
$$ will extract a single element of a list by name.
[1] 4 5 6
Permits partial matching.
A list is a non-atomic vector that can contain:
Draw the train:
Draw the train and then write the R code to extract:
"rabbit”"rabbit"y1:32.02:00
