Lists
- A list overall, has it’s own reference (id)
- List elements also each point to other values
- List doesn’t store the value, it stores a reference to the value
- As of R 3.1.0, modifying lists creates a shallow copy
- References (bindings) are copied, but values are not
- We can use
ref()
to see how they compare- See how the list reference is different
- But first two items in each list are the same
ref(l1, l2)
#> █ [1:0x557c2b761538] <list>
#> ├─[2:0x557c2b559710] <dbl>
#> ├─[3:0x557c2b559550] <dbl>
#> └─[4:0x557c2b559390] <dbl>
#>
#> █ [5:0x557c2b4925d8] <list>
#> ├─[2:0x557c2b559710]
#> ├─[3:0x557c2b559550]
#> └─[6:0x557c2b5580c0] <dbl>