[R] How to use getSymbols() to get annual data

Duncan Murdoch murdoch.duncan at gmail.com
Sat Sep 2 14:15:18 CEST 2017


On 01/09/2017 7:37 PM, Yingrui Liu wrote:
> Dear Sir/Madam,
> 
> 
> How to use getSymbols() to get annual data? For example, I need the annual stock price of APPLE from the year 2000 to 2016. How to write the command? I only know how to get the daily data. It is:
> 
> 
> getSymbols("AAPL",from="2000-01-01",to="2016-12-31")
> 
> 

Presumably you'd need to loop over the years:  get all the daily data in 
a year, calculate the overall High and Low, take the Open from the first 
date, the Close from the last one, and repeat.

Duncan Murdoch



More information about the R-help mailing list