Suppose I have a list
of vectors (none of them is empty; they may be of various lengths).
How can I generate a list of elements from the ends (say) of the vectors?
For example, if my list contains 3 elements, 1:10
, 2:9
and c(3,5)
, then the output list should be the list containing 10
, 9
and 5
.
In the simpler case, where all vectors are of the same length (5, say), I tried to first make the list a data.frame
using as.data.frame
. The problem is that my list is huge (about 1 million vectors), and as.data.frame
takes ages. I thought about optimization, perhaps using this answer, but anyway I think that it results a wrong data structure - instead of having 5 columns with 1 million values each, it creates a data.frame
with a million columns.
So I should probably look somewhere else. Any ideas?