rmysql return data type
Question
I am extracting some data from a db using R and RMySQL and the dates come back as factors. I then have to call as.Date()
on this column. Because there are a lot of records, this takes a long time. Is there a way to strong type the return values from fetch
? That is, just like read.csv
, for example, allows you to specify column types to prevent R from automatically trying to recognize them, is there something like this available? The dates in my db are typed as Date
.
Solution
Bad luck. The RMySQL documentation has this to say: "Time variables are imported/exported as character data, so you need to convert these to your favorite date/time representation." So you'll always have to convert.
RODBC seems to properly support dates tough.