subset list of xts objects

2019-05-30 08:19发布

问题:

There's a great post on here that has clear examples of subsetting an xts object: Return data subset time frames within another timeframes?

However, I have list of xts objects and I am looking to subset each component of this list by gathering all the observations from a specified date onward. So, something like this, but for each xts object in the list:

my_xts["2011/"]

Thank you for all your help!

回答1:

You can use lapply to loop over all the elements in your list, and use an anonymous function to subset them.

lapply(xts_list, function(x) x["2011/"])


标签: r list subset xts