Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 87

Convert list to vectors

Оглавление

Vectors can only contain one type of variable, while a list can be of mixed types. It might make sense to convert lists to vectors, for example, because some operations on vectors will be significantly faster.

unlist()

To do this R, provides the function unlist().

L <- list(c(1:5), c(6:10)) v1 <- unlist(L[1]) v2 <- unlist(L[2]) v2-v1 ## [1] 5 5 5 5 5

The Big R-Book

Подняться наверх