Suppose I have a dataset that looks like the following, in which years are listed down rows:
id<-c(1,1,1,2,2,2,3,3,3) year<-c(1990, 1991, 1992, 1992, 1
these days using tidyverse is more the rage:
library(tidyr) dataset %>% spread(year, N, fill = 0)