<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>I having trouble getting getSymbols() to work with a CSV file.  I am not sure<br>if this is a bug report, or my lack of understanding on how to pass the format<br>argument to getSymbols.csv().  Please read on.<br><br>I am running R-2.14.1 on WinXp, xts 0.8-2 and zoo 1.7-6<br><br>I noticed the docs mentioned this not being tested on windows, so I went ahead<br>dug into the problem a little bit.<br><br>getSymbols() reads the file in, but the dates for every row are all set to<br>todays date.  Now the data I am working with is from 1999, so that's the heart<br>of the problem; why is the date getting lost? <br><br>Here is a log of my work, mostly reproduceable:<br><br># Data as found in file EURUSD.csv: (see attached for full file)<br>#<br># Date,Open,High,Low,Close,Volume,Adjusted<br>#
 1999-01-04,1.174,1.189,1.174,1.177,1,0<br># 1999-01-05,1.183,1.183,1.175,1.177,1,0<br>#  .... rows snipped<br># 1999-01-28,1.1441,1.1468,1.1383,1.1412,1,0<br># 1999-01-29,1.1413,1.143,1.1343,1.1357,1,0<br><br>library(quantmod) ;<br>setwd("C:/storage") ; # set as necessary<br>getSymbols("EURUSD", src='csv') ;<br><br><br># How did the dates get mangled???<br>tail(EURUSD) <br><br>           EURUSD.Open EURUSD.High EURUSD.Low EURUSD.Close EURUSD.Volume EURUSD.Adjusted<br>2012-03-03      1.1593      1.1625     1.1562       1.1585             1               0<br>2012-03-03      1.1585      1.1609    
 1.1549       1.1549             1               0<br>2012-03-03      1.1551      1.1588     1.1551       1.1560             1               0<br>2012-03-03      1.1561      1.1561     1.1411       1.1423             1               0<br>2012-03-03      1.1441      1.1468    
 1.1383       1.1412             1               0<br>2012-03-03      1.1413      1.1430     1.1343       1.1357             1               0<br><br><br><br><br>So I dug into getSymbols.csv() a little bit and managed to get the data file<br>loaded fine by parroting the guts of getSymbols.csv() as follows:<br><br><br><br>############################################################<br>## THIS WORKS<br>library(quantmod) ;<br>setwd("C:/storage") ; # set as necessary<br>EURUSD <-read.csv("C:/storage/EURUSD.csv") ;<br><br><br>EURUSD <- xts(EURUSD[, -1], as.Date(EURUSD[,
 1]) , src = "csv", updated = Sys.time())<br><br><br>colnames(EURUSD) <- paste(toupper(gsub("\\^", "", "EURUSD"  )), <br>            c("Open", "High", "Low", "Close", "Volume", "Adjusted"), <br>            sep = ".")<br><br>> tail(EURUSD)<br>           EURUSD.Open EURUSD.High EURUSD.Low EURUSD.Close EURUSD.Volume EURUSD.Adjusted<br>1999-01-22      1.1593      1.1625     1.1562       1.1585             1               0<br>1999-01-25      1.1585      1.1609    
 1.1549       1.1549             1               0<br>1999-01-26      1.1551      1.1588     1.1551       1.1560             1               0<br>1999-01-27      1.1561      1.1561     1.1411       1.1423             1               0<br>1999-01-28      1.1441      1.1468    
 1.1383       1.1412             1               0<br>1999-01-29      1.1413      1.1430     1.1343       1.1357             1               0<br><br>Now EURUSD looks as expected.<br><br>############################################################<br><br><br>One difference from my parroted code and that found in getSymbols.csv() is I did<br>not use the format argument when constructing the xts object from the data.frame.<br><br>getSymbols.csv() uses this code:<br><br>fr <- xts(fr[, -1], as.Date(fr[, 1], format = format, <br>    ..., origin =
 "1970-01-01"), src = "csv", updated = Sys.time())<br><br><br>while I did this:<br><br>EURUSD <- xts(EURUSD[, -1], as.Date(EURUSD[, 1]) , src = "csv", updated = Sys.time())<br><br> From what I could follow in the getSymbols.csv() code the format is getting<br>set to the empty string ""<br><br>Now if I plug in an empty format to my code as follows I get the same screwy munging of the dates:<br><br>EURUSD <- xts(EURUSD[, -1], as.Date(EURUSD[, 1], format = "", <br>            , origin = "1970-01-01"), src = "csv", updated = Sys.time())<br><br><br>> tail(EURUSD)<br>             Open   High    Low  Close Volume Adjusted<br>2012-03-03 1.1593 1.1625 1.1562 1.1585      1        0<br>2012-03-03 1.1585 1.1609 1.1549
 1.1549      1        0<br>2012-03-03 1.1551 1.1588 1.1551 1.1560      1        0<br>2012-03-03 1.1561 1.1561 1.1411 1.1423      1        0<br>2012-03-03 1.1441 1.1468 1.1383 1.1412      1        0<br>2012-03-03 1.1413 1.1430 1.1343 1.1357      1        0<br><br>Ah, ha! Seems like format is the key.<br><br>And if I use a proper format (or no format at all) to the xts call it seems to<br>work as expected:<br><br>EURUSD <- xts(EURUSD[, -1], as.Date(EURUSD[, 1], format = "%Y-%m-%d", <br>            , origin = "1970-01-01"), src = "csv", updated = Sys.time())<br><br>>
 tail(EURUSD)<br>             Open   High    Low  Close Volume Adjusted<br>1999-01-22 1.1593 1.1625 1.1562 1.1585      1        0<br>1999-01-25 1.1585 1.1609 1.1549 1.1549      1        0<br>1999-01-26 1.1551 1.1588 1.1551 1.1560      1        0<br>1999-01-27 1.1561 1.1561 1.1411 1.1423      1        0<br>1999-01-28 1.1441 1.1468 1.1383 1.1412      1        0<br>1999-01-29 1.1413 1.1430 1.1343 1.1357      1        0<br></span></div><div><br><span></span></div><div><span>That looks
 good.</span></div><div><span><br></span></div><div><span>One last note.   I tried adding the format argument to getSymbols() thinking it would get passed along to getSymbols.csv() but the following error message was produced:<br><br>getSymbols("EURUSD", src='csv', format = "%Y-%m-%d" ) ;<br><br>Error in list(...)[["format"]] <- NULL : <br>  '...' used in an incorrect context<br></span></div><div> <br>Any guidance offered would be greatly appreciated.<br><br></div><div>--<br>Stergios Marinopoulos</div></div></body></html>