I want to filter a base where I have the variables id, year and value.
structure(list(id = c(
70101L, 70101L, 70101L, 70102L, 70102L,
70102L, 70102L, 70102L, 70103L, 70103L, 70103L, 70103L, 70103L,
70103L, 70104L, 70104L, 70104L, 70104L, 70104L, 70104L
), year = c(
2013L,
2014L, 2015L, 2013L, 2014L, 2015L, 2016L, 2017L, 2013L, 2014L,
2015L, 2016L, 2017L, 2018L, 2013L, 2014L, 2015L, 2016L, 2017L,
2018L
), value = c(
4.68, 4.76, 5.14, 4.48, 4.71, 4.24, 5.13, 5.22,
5.13, 5.05, 4.96, 5.09, 8.09, 7.82, 3.57, 7.96, 1.83, 4.56, 11,
10.6
)), row.names = c(NA, -20L), class = "data.frame")
Goal
Filter the ids that only have complete information from the years 2013 to 2018
id year value
<fct> <dbl> <dbl>
1 070103 2013 5.13
2 070103 2014 5.05
3 070103 2015 4.96
4 070103 2016 5.09
5 070103 2017 8.09
6 070103 2018 7.82
7 070104 2013 3.57
8 070104 2014 7.96
9 070104 2015 1.83
10 070104 2016 4.56
11 070104 2017 11.0
12 070104 2018 10.6