I have a column variable in my data that is a time range: datesemployed
. Sample data is below:
name datesemployed university
Kate Oct 2015 – Jan 2016 Princeton
Sue Nov 2015 – Dec 2017 Pomona
I want to separate rows such that each year in the time range has its own row:
name datesemployed university
Kate 2015 Princeton
Kate 2016 Princeton
Sue 2015 Pomona
Sue 2016 Pomona
Sue 2017 Pomona
In a separate post, the solution was to separate rows based on -
. But that solution only works if the time range is always one year. If the data were 2015-2017
for example, I would be missing a row for 2016.
The separate_rows
syntax from the previous answer makes a lot of sense to me, but I'm not sure how to adapt it to this situation, or if it's even possible to do so. I've also found that with large frames of data (~1000 observations), separate_rows
is really slow, and freezes R for me.