I have a data.frame with two columns. Both, dates as characters:
a <- c("01-01-2007 00:00:00", "01-02-2007 00:00:00", "03-05-2007 00:00:00", "31-08-2007 00:00:00")
b <- c("01-01-1960 01:25:30", "01-01-1960 1:05:36", "01-01-1960 02:25:59", "01-01-1960 1:20:30")
df <- as.data.frame(cbind(a,b))
df
a b
1 01-01-2007 00:00:00 01-01-1960 01:25:30
2 01-02-2007 00:00:00 01-01-1960 1:05:36
3 03-05-2007 00:00:00 01-01-1960 02:25:59
4 31-08-2007 00:00:00 01-01-1960 1:20:30
The first column have dates that I need, but time is incorrect. Time is correct in the second column, but dates aren't. The second column also have the problem that, in some rows hours have only one digit.
What I need is a merge between two columns in a time format that I can use to represent counts frequency by time.
I've tried a lot of different combinations to merge both columns but I always get an error. as.Date()
don't keep me time, and I can't apply as.POSIXct
in the data.frame.
I would appreciate some help.
Thanks