I have a dataset, where I would like to duplicate rows based on specific values.
Let's say I have a sample election dataset
vote_share county year
0.6 A 2016
0.4 B 2016
0.2 C 2016
0.8 A 2012
0.1 B 2012
0.3 C 2012
I would like to create duplicates of the same values for the intervening years: year 2012 values for each county for also years 2013-2015; the same for 2017-2019 with 2016 values.
I'm not sure whether I should be doing this with loops or perhaps with tidyverse?