I have a list of xts objects. I’d like to get a data.frame with the last lines of each levels of the list.
My list looks like:
a <- xts(matrix(1:4,2),as.Date("2012-01-01")+0:1)
b <-list(a,a*5)
> b
[[1]]
[,1] [,2]
2012-01-01 1 3
2012-01-02 2 4
[[2]]
[,1] [,2]
2012-01-01 5 15
2012-01-02 10 20
I would like to get:
[,1] [,2]
2 4
10 20
The column names are the same in each levels of the list.
In addition to @Henrik’s answer, you could also use a combination of
lapply,do.call, andlast: