Setting the last date collected to be a Monday

2019-06-08 02:04发布

I can download a data set using Quantmod

library(quantmod)
getSymbols("SPY", from="2013-01-01", to=Sys.Date())
chartSeries(SPY)

I would like the last data to be collected to be always on a Monday (so if I collect data on say Thursday, the Tuesday,Wednesday and Thursday data points will be filtered out). Is there a way to do this.

Thank you for your help.

标签: r quantmod
1条回答
Lonely孤独者°
2楼-- · 2019-06-08 02:24

replace your to=Sys.Date() with to=(Sys.Date()-c(6:0))[format((Sys.Date()-c(6:0)),"%w")=="1"]

查看更多
登录 后发表回答