Return data subset time frames within another timeframes?

前端 未结 3 573
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 17:01

There are very nifty ways of subsetting xts objects. For example, one can get all the data for all years, months, days but being strictly between 9:30 AM and 4

3条回答
  •  温柔的废话
    2020-11-29 17:33

    You can use the .index* family of functions to get certain months or certain days of the month. See ?index for the full list of functions. For example:

    library(quantmod)
    getSymbols("SPY")
    SPY[.indexmon(SPY)==0]   # January for all years (note zero-based indexing!)
    SPY[.indexmday(SPY)==1]  # The first of every month
    SPY[.indexwday(SPY)==1]  # All Mondays
    

提交回复
热议问题