I would like to compute the difference between the treecover in year n and year n-1 of each protected area (for ex, treecover of Mont Peko National Park in 2001 - treecover of Mont Peko National Park in 2000). Please see below the screenshot.
I tried this :
treeloss <- treeloss %>%
mutate(treecov_var = diff(treecover))%>%
But I get an error message : Error in
! Problem while computing
treecov_var = diff(treecover).
treecov_var must be size 21 or 1, not 20.
The error occurred in group 1: nm_ap = "Aiguille de Prony".
rlang::last_error() to see where the error occurred.
What is the issue ?