I am importing a data frame into R, but R is not recognizing the columns with the dates as being in dates format.
> mydata[1,1]
[1] 1/1/2003 0:00
216332 Levels: 1/1/2003 0:00 1/1/2003 0:15 1/1/2003 0:30 ... 9/9/2007 9:55
I tried:
> as.Date(mydata[1,1], format = "%m/%d/%Y %H:%M")
[1] "2003-01-01"
But then I miss the time.
If I do
> strptime(mydata[2,1], format = "%m/%d/%Y %H:%M")
[1] "2003-01-01 00:15:00 EST"
I get what I need. However it does not work when I assign this result to my variable
> mydata[,1] <- strptime(mydata[,1], format = "%m/%d/%Y %H:%M")
Warning message:
In `[<-.data.frame`(`*tmp*`, , 1, value = list(sec = c(0, 0, 0, :
provided 11 variables to replace 1 variables
My question is similar to the question at Set time value into data frame cell
Although, it is well explained, after spending some time reading and trying I could not figure that out on my own.