My data is like this. df is the name of the dataframe
Status ArrivalDate ClosedDate
Closed 2015-12-01 04:40:24 2015-12-08 10:12:08
In Progress 2015-12-03 06:40:00
Pending 2015-12-12 08:40:54
Cancelled 2015-12-06 04:40:24 2015-12-18 11:33:50
Status has 4 factors:Closed,Cancelled,In-Progress,Pending In-Progress and Pending don't have ClosedDates
I want to create another column which gives the time difference between ArrivalDate and ClosedDate only if Status is Closed or Cancelled.
This is the code i'm using now:
df$Life[df$Status=="Closed"|df$Status=="Cancelled"]<-difftime(df$Arrival.Date,df$Closed.Date)
And this is the error message I'm getting
Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format
PS: difftime()
works properly when I tried with just two dates. When extended to the whole column it shows the error.