Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 83
Lists of Lists Are Also Lists
ОглавлениеV1 <- c(1,2,3) L2 <- list(V1, c(2:7)) L3 <- list(L2,V1) print(L3) ## [[1]] ## [[1]][[1]] ## [1] 1 2 3 ## ## [[1]][[2]] ## [1] 2 3 4 5 6 7 ## ## ## [[2]] ## [1] 1 2 3 print(L3[[1]][[2]][3]) ## [1] 4
Note how the list L3
is a list of lists, rather than the concatenation of two lists. Instead of adding the elements of L2 after those of V1 and having nine slots for data, it has two slots. Each of those slots contains the object V1
and L2
respectively.