문제

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)
도움이 되었습니까?

해결책

User character subsetting.

AAPL[paste(Sys.Date()-365, Sys.Date(), sep="/")]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top