Basically, my data is grouped by days with an inconsistent number of rows in between:
16-Oct-16
Name1
Name2
Name3
17-Oct-16
Name1
Name2
Name3
Name4
Name5
19-Oct-16
etc.
I need to be able to grab the group data and apply it to the child records. The expected result should look as follows:
Name1 16-Oct-16
Name2 16-Oct-16
Name3 16-Oct-16
Name1 17-Oct-16
Name2 17-Oct-16
Name3 17-Oct-16
Name4 17-Oct-16
Name5 17-Oct-16
I'm using data.table
but currently I can't think of any way other than a loop.
The following script generates the kind of dataset I'm looking at:
data.table(c('October 16, 2016', paste0('Name',1:4),
'October 17, 2016', paste0('Name',1:12),
'October 20, 2016', paste0('Name',1:2),
'October 25, 2016', paste0('Name',1:6)))
I just want to copy the appropriate date field to each name row and end up with a tidy dataset where each row has name and date.