I am using a dataset to calculate the growth in earnings from 2000-2019 and have the earnings for every month within those years. It is in the ymd format, eg 2000-01-01
I am trying to calculate the growth rate between each month but it won't let me use the lag function properly due to the year column being in date format as above.
average_weekly_earnings <- average_weekly_earnings %>%
mutate(diff_earnings_average = year - lag(year),
diff_aveearnings_growth = realawe - lag(realawe),
Error in' /.difftime'(diff_aveearnings_growth, diff_earnings_average) : second argument of / cannot be a "difftime" object
This code appears when I try to run it.
Does anyone known how to fix this?