Hello,
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 %>%
group_by(nm_ap) %>%
mutate(treecov_var = diff(treecover))%>%
ungroup()
But I get an error message : Error in mutate()
:
! 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".
Run rlang::last_error()
to see where the error occurred.
What is the issue ?
thank you
regards