I have tdateIn, dateOut
, and I want to produce the result dateOut - dateIn
as new column. My problem is in the format of my dates:
## format of my date: 20140424_195711000
typeof(test$dateIn); typeof(test$dateOut)
[1] "integer"
[1] "integer"
I tried everything but I get NA
as result or error:
date <- as.Date(as.character(dateIn), format("%Y%m%d %H%M%S"))
> date
[1] NA
as.POSIXct(dateIn, format="%Y%m%d %H%M%S")
Error in as.POSIXct.default(t, format = "%Y%m%d %H%M%S") :
do not know how to convert 't' to class "POSIXct"
I tried to do that directly:
diff = dateOut - dateIn
[1] NA
Warning message:
In Ops.factor(test$STEP_DATE_TIME_OUT[1], test$STEP_DATE_TIME_IN[1]) :
- not meaningful for factors
I do not where is the problem? In the underscore? Or in the type of my variables dateIn
and dateOut
?