I have dataframe and there two columns of 1st_date date and 2nd_date. I used difftime()
function to calculate the difference by days, and it did the job.
However, I found an incorrect value when I checked all values generated by difftime()
The incorrect value I have is:
1st_date 2nd_date time_diff
12/31/68 12:11 1/13/69 19:29 -36512
while it should be:
1st_date 2nd_date time_diff
12/31/68 12:11 1/13/69 19:29 13
the command I used is :
df$time_diff <- difftime(as.Date(df$1st_date, format="%m/%d/%y"),
as.Date(df$2nd_date, format="%m/%d/%y"),
units = "days")
Any one can explain how did that happen and how to handle it?