I have a database where I have a list of ocurrences with three sets of dates and times (total of six columns). I want to convert this to POSIX to manipulate later. The problem is that after creating three new columns to paste the date and time to a single string, when I try to convert to POSIX, only the first one is sucessful, the last two contain only the date.
At first I thought that maybe some entries didn't have a time, but I checked and there are rows where there are both things and only date is returned.
The date is in an european format first, the columns with dates and times are also factors when I read the data. I'm using as.Date(data$DateAlert, format = '%d/%m/%Y')
to convert to the new format and later I'm using paste(data$DateAlert, data$HourAlert)
, creating a string in the POSIX format like 2001-07-29 14:53:10
. I have confirmed that the columns containing these strings are in the type character, so I guess POSIXct wouldn't have much trouble with it.
Before converting to POSIX, I get something like this:
$ Alert : chr "2001-07-29 15:32:00" "2001-07-02 12:59:00" "2001-07-31 23:37:00" "2001-08-01 17:02:00"
$ Complete : chr "2001-07-29 17:20:00" "2001-07-03 02:39:00" "2001-08-01 02:53:00" "2001-08-01 17:24:00"
$ Inter : chr "2001-07-29 14:53:10" "2001-07-02 12:26:32" "2001-07-31 22:37:57" "2001-08-01 16:19:25"
After converting to POSIX, using as.POSIXct()
I get something like this:
$ Alert : POSIXct, format: "2001-07-29 15:32:00" "2001-07-02 12:59:00" "2001-07-31 23:37:00" "2001-08-01 17:02:00" ...
$ Complete : POSIXct, format: "2001-07-29" "2001-07-03" "2001-08-01" "2001-08-01" ...
$ Inter : POSIXct, format: "2001-07-29" "2001-07-02" "2001-07-31" "2001-08-01" ...
Any idea of what am I doing wrong? I haven't found any similar thread with this problem