Sequentially extract elements from vectors of equal length in a list.

extract(lst, num = min(lengths(lst)))

Arguments

lst
A list of vectors of equal length, a data frame, or a matrix. If the length of the smallest vector in lst is smaller than num then an error will be thrown (subscript out of bounds).
num
A number (preferably the length of the vectors) to create a sequence for extract() to extract the elements of lst. Default value is the length of the shortest vector in the list.

Examples

# 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))