Reputation: 5807
I'm programming a function in which I want to plot let's say the stock price for any stock during the last 365 days. However not trading days, but just a one year period. So if I'm generating the chart on the 15th of February I want data from the 16th February 2012-15th February 2013. How can I do that? last() for example shows me the last 365 trading days or days of which there is data available.
library(quantmod)
getSymbols("AAPL")
plot(AAPL)
Upvotes: 0
Views: 156
Reputation: 49810
User character subsetting.
AAPL[paste(Sys.Date()-365, Sys.Date(), sep="/")]
Upvotes: 2