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
  • 745
  • 1
  • 13
  • 22

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
  • 173,410
  • 32
  • 338
  • 418