1

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!

Community
  • 1
  • 1
jonnie
  • 725
  • 12
  • 20

1 Answers1

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/"])
Joshua Ulrich
  • 168,168
  • 29
  • 327
  • 408