1

try following code

sp500 <- new.env()

getSymbols("^GSPC", env = sp500, src = "yahoo",
           from = as.Date("2008-01-04"), to = Sys.Date())

GSPC <- get("GSPC", envir = sp500) 

and the date is offset:

2013-03-03   1518.20   1525.27  1512.29    1525.20  3414430000       1525.20
2013-03-04   1525.20   1543.47  1525.20    1539.79  3610690000       1539.79
2013-03-05   1539.79   1545.25  1538.11    1541.46  3676890000       1541.46
2013-03-06   1541.46   1545.78  1541.46    1544.26  3634710000       1544.26
2013-03-07   1544.26   1552.48  1542.94    1551.18  3652260000       1551.18
2013-03-10   1551.15   1556.27  1547.36    1556.22  3091080000       1556.22
2013-03-11   1556.22   1556.77  1548.24    1552.48  3274910000       1552.48
2013-03-12   1552.48   1556.39  1548.25    1554.52  3073830000       1554.52
2013-03-13   1554.52   1563.32  1554.52    1563.23  3459260000       1563.23
2013-03-14   1563.21   1563.62  1555.74    1560.70  5175850000       1560.70

the 2013-03-10 is Sunday...

Any ideas? thank you in advance.

Here is my sessionInfo output, and I've updated two packages, but the issue is still there:

 ===============================================================
R version 2.15.2 (2012-10-26)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] quantmod_0.4-0 TTR_0.21-1     xts_0.9-3      zoo_1.7-7      Defaults_1.1-1
[6] RMySQL_0.9-3   DBI_0.2-5     

loaded via a namespace (and not attached):
[1] grid_2.15.2     lattice_0.20-10 tools_2.15.2   
4

0 回答 0