I have a large file with more than 20 Million Rows. It has 5 date fields each of which is in a character format like this: "2012-12-31". After importing with a read.table
, it gets imported as a 'character' field.
I can convert it to POSIXlt with the following code, but it takes a long time to process. I want to avoid this step and have the date field imported as POSIXlt class directly. Is there a way to do this ?
Other things I have tried is using the colClasses argument in read.table command as a vector of "as.POSIXlt"s as well as "POSIXlt"s. It doesnt seem to work.
input[, c (names (input) %in% c ("DATE1", "DATE2", "DATE3", "DATE4", "DATE5"))] <- sapply(input[,
c(names(input) %in% c("DATE1", "DATE2", "DATE3", "DATE4", "DATE5"))], FUN = function(x) as.POSIXlt(as.character(x))})