If we have a list, and each item can have different length. For example:
l <- list(c(1, 2), c(3, 4,5), c(5), c(6,7))
(In order to be cl
# the source list source_list <- list(c(1, 2), c(3, 4,5), c(5), c(6,7)) # the index of the elements you want k <- 1 # the results character vector x <- c() for (item in source_list) { x <- append(x, item[k]) } print(x) [1] 1 3 5 6