I combined datasets and I run the following function but it returned an error message indicated below. I also run a str function and I observed that the date format is displayed as mdy as is on the original datasets and the result for a numeric value is NA
all_trips$ride_length<-difftime(all_trips$ended_at,all_trips$started_at)
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
4/1/2019 0:02" "4/1/2019 0:03" "4/1/2019
num NA ..
The difftime() function only takes POSIXct or date class objects as arguments and you are passing string class values. You need to convert them first, take a look at this example:
difftime(as.POSIXct("4/1/2019 0:03", format = "%m/%d/%Y %H:%M", tz = "UTC"),
as.POSIXct("4/1/2019 0:02", format = "%m/%d/%Y %H:%M", tz = "UTC"))
#> Time difference of 1 mins