I want to create a aggregation structure in a database by using a parent-child relationship like the one in this dataframe:
df <- data.frame(Child=c("C","C11","C111","C112","C12","C121","C122","C123","C13","C131","C132"),
Parent=c("","C","C11","C11","C","C12","C12","C12","C","C13","C13"))
From this parent-child dataframe, I would like to get lists like this (for further use in a function):
list.C <- c("C11","C12","C13")
list.C11 <- c("C111","C112")
list.C12 <- c("C121","C122","C123")
list.C13 <- c("C131","C132")
I've been trying to create my list with a loop through the lines and an assign function, but didn't work... any idea how to create this -- or list vectors?
Thank you!