Вот подход с использованием data.table.
library(data.table)
setDT(data)[order(year),][,
lapply(.SD,cumsum),
by="placette",
.SDcols = setdiff(names(data),c("placette","year"))][
,N.Years := 1:.N,by="placette"][]
# placette N.Years SP1 SP2
# 1: 1 1 43 4
# 2: 1 2 43 4
# 3: 1 3 59 7
# 4: 1 4 113 11
# 5: 2 1 30 0
# 6: 2 2 32 2
# 7: 2 3 48 3
# 8: 2 4 99 5
# 9: 3 1 23 3
#10: 3 2 28 3
#11: 3 3 48 3
#12: 3 4 99 3
Данные
data <- structure(list(placette = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L,
1L, 2L, 3L), year = c(2013L, 2013L, 2013L, 2014L, 2014L, 2014L,
2015L, 2015L, 2015L, 2016L, 2016L, 2016L), SP1 = c(43L, 30L,
23L, 0L, 2L, 5L, 16L, 16L, 20L, 54L, 51L, 51L), SP2 = c(4L, 0L,
3L, 0L, 2L, 0L, 3L, 1L, 0L, 4L, 2L, 0L)), class = "data.frame", row.names = c(NA,
-12L))