subset list of xts objects

南楼画角 提交于 2019-12-08 08:28:14

问题


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/"])


来源:https://stackoverflow.com/questions/24683531/subset-list-of-xts-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!