I have data in this form, where a separate column is included in a separate row at the start of group of detail records
data <- data.frame(detail = c("", "Sue", "Fred", "", "Jayne", "Harold", "Jim"),
group = c("Group 1", "", "", "Group 2", "", "", ""))
I want to reshape it as follows. Can this be done with pivot_wider?
Detail | Group No |
---|---|
Sue | Group 1 |
Fred | Group 1 |
Jayne | Group 2 |
Harold | Group 2 |
Jim | Group 2 |