[R] read.table behavior for Dates.

Jeroen Ooms jeroenooms at gmail.com
Fri Apr 16 21:32:55 CEST 2010


When read.table imports a table that includes a header called 'Date', it
tries to recognize the date format. For example, if one imports this data
from Yahoo finance, the Date column is automatically transformed to Y-m-d,
whereis in the data it appears as m/d/Y:

myData <-
read.csv("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=07&b=19&c=2004&d=03&e=16&f=2010&g=d&ignore=.csv")

However, it does not actually convert the variable to Date format.
MyData$Date is still a factor. This combination of converting the format but
not attributing the 'Date' class is for me extremely unfortunate behavior.
My scripts still don't recognize the variable as being a date, but it also
becomes harder to manually convert it using as.Date() because it is no
longer in the original format.

Is there a way to either automatically convert to as.Date() when a date
format has been detected, or otherwise disable this transformation at all?


-- 
View this message in context: http://n4.nabble.com/read-table-behavior-for-Dates-tp2013442p2013442.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list