Frage

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)
War es hilfreich?

Lösung

User character subsetting.

AAPL[paste(Sys.Date()-365, Sys.Date(), sep="/")]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top