I have an R data.frame with the following data:
# A tibble: 21 x 57
# Groups: section [21]
section `1965` `1966` `1967` `1968` `1969`
<fct> <int> <int> <int> <int> <int>
1 A 3 63 114 173 257
2 B 2 88 114 147 169
3 C 26 708 892 1101 1339
4 D 1 16 16 20 77
In the complete data.frame the columns range from 1965->2020 and each row is a section A->U.
I would like to add new columns to the right with the difference between successive columns: 1966-1965 data for each Section (Row), then 1967-1966 for each row, 1968-1967 and so on until 2020-2019 as the last new column.
I have tried a few implementations of mutate_all() but to no success.
Any suggestion is highly appreciated!
Cheers