Setting the last date collected to be a Monday

不想你离开。 提交于 2020-01-02 23:00:55

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19320614/setting-the-last-date-collected-to-be-a-monday

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