I have a data frame with Id Column & Date Column.
Essentially, I would like to create a third column (Diff) that calculates the difference between dates, preferably grouped by ID.
I have constructed a large POSIXlt from the following code
c_time <- as.POSIXlt(df$Gf_Date)
a <- difftime(c_time[1:(length(c_time)-1)], c_time[2:length(c_time)], units = weeks")
However when I try cbind
onto my data.frame it errors
"arguments imply differing number of rows"
as a is one row shorter than the original data.frame.
Any help would be greatly appreciated.