I am trying to create a new calculated field, length_of_time
. I have a column final_date with dates:
2/10/2016
4/4/2016
5/8/2016
10/1/2016
and I am trying to calculate a new field showing length of time between 10/23/2016 and final_date.
I tried using dplyr:
mutate(df, length_of_time = 10/23/2016 - final_date)
and received an error:
"Error in eval(substitute(expr), envir, enclos) : can only subtract from "POSIXt" objects"
so then I tried to use:
df <- as.POSIXlt(df$final_date)
and again ran my original code, only to receive the following error:
Error in UseMethod("mutate_") :
no applicable method for 'mutate_' applied to an object of class "c('POSIXlt', 'POSIXt')"