I'm having a similar question to this one (subtract value from previous row by group), but I want to subtract the previous date from the current date, by group ID in order to have an estimated number of days. I tried editing the scripts suggesed previously by replacing "value" by "date". Although I tried different suggested methods, but i keep getting this error message "Error in mutate_impl(.data, dots) : Evaluation error: unable to find an inherited method for function first for signature "POSIXct"."
Data
id date
2380 10/30/12
2380 10/31/12
2380 11/1/12
2380 11/2/12
20100 10/30/12
20100 10/31/12
20100 11/1/12
20100 11/2/12
20103 10/30/12
I'd like to get this kind of table
Data
id date date_difference(in days)
2380 10/30/12 0
2380 10/31/12 1
2380 11/1/12 2
2380 11/2/12 3
20100 10/30/12 0
20100 10/31/12 2
20100 11/1/12 3
20100 11/2/12 4
20103 10/30/12 0
20103 10/31/12 1