Search code examples
rdatedatetimeposixct

Conversion of raw data to R date/time class


I've successfully scraped a bunch of tables that I now want to manipulate in R. I'm new to R, but this seems like a good way to figure it out.

I currently have data stored in a bar-delimited CSV that looks like about this:

FIRST|LAST|9812036311|string-string|1999-07-06 00:00:00|2000-07-06 00:00:00|12345|1999-07-27 00:00:00|2,518.50

I can read it in with:

j <- read.table('my_data.csv', header = FALSE, sep = "|")

but ... how do I transform those date columns into dates that R can read?

Do I need to define a frame first?


Solution

  • It turns out I just needed as.Date -- as a sanity check, I created a new column with the modified date.

    j$better.date <- as.Date(j$original.date, format="%Y-%d-%m")