[
The image above shows the first ~20 rows of my df.
The goal is to move the b3_01 - b3_10 rows to be on the same height as rows that have a number in the v011 column. For example, caseid #4 is the mom and case ids #5 and 6 are her kids. I want both of the 1297s to be next to the 973.
I'm stumped!
structure(list(caseid = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), v008 = c(1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417, 1417), v011 = c(1081, NA, NA, 973, NA, NA, NA, 709, NA, NA, NA, 1045, NA, NA, NA, 877, NA, NA, NA, 685), b3_01 = c(NA, NA, NA, NA, 1297, NA, NA, NA, 1189, NA, NA, NA, NA, 1405, NA, NA, NA, NA, 1297, NA), b3_02 = c(NA, NA, NA, NA, NA, 1297, NA, NA, NA, NA, NA, NA, 1393, NA, NA, NA, NA, 1225, NA, NA), b3_03 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1189, NA, NA, NA), b3_04 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_05 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_07 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_08 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_09 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), b3_10 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), row.names = c(NA, -20L), class = c("tbl_df", "tbl", "data.frame"))
So far I tried to bump up the b3_01-b3_10 values, by they are not always the same distance apart (e.g. b3_01 is not always 1 below v011).
## Not the solution, but nice try
hello4 <- hello4 %>%
mutate_at(c("b3_01"), funs(lead), n = 1)
hello4 <- hello4 %>%
mutate_at(c("b3_02"), funs(lead), n = 2)
hello4 <- hello4 %>%
mutate_at(c("b3_03"), funs(lead), n = 3)
etc.