Sequentially extract elements from vectors of equal length in a list.
extract(lst, num = min(lengths(lst)))
lst
is smaller than
num
then an error will be thrown (subscript out of bounds
).extract()
to extract the elements of lst
. Default
value is the length of the shortest vector in the list.# x <- list(a = 1:5, b = 6:9) ## Does not extract last element in x$a; does not throw an error # extract(x, length(x$b)) ## Throws an error because num (length(x$a)) is greater than the number of ## elements in x$b (greater than length(x$b)). #extract(x, length(x$a))