r – Transform panel data of static values ​​to panel dataset of changes from previous period for several variables

I have a panel dataset that looks something like: df <- data.frame(id = c(1:10), income_3 = c(2:11), income_4 = c(3:8, NA, 10:12), income_5 = c(4:13), health_3 = c(NA, 6:14), health_4 = c(7:10, NA, 11:15), health_5 = c(9:18)) id income_3 income_4 income_5 health_3 health_4 health_5 1 2 3 4 NA 7 9 2 3 4 5 … Read more