Bellow are 2 list which i want to manipulate. The first list, list1, contains three elements with random numbers. The second one is pretty much the same but it has one layer more on top of it (lev).
The goal is to "transfer" information from list2 for each elem into list1 while keeping track of lev layer and encoding it as name.
Bellow is the for loop that works, what would be the purrr equivalents?
for (lev in names(list2)) {
for(elem in names(list2[[lev]])) {
new_name <- paste(lev, elem, sep = "_")
list1[[elem]][[new_name]] <- list2[[lev]][[elem]]
}
}
I was also having an impression that a for loop is more reasonable in this situation. I would say the way to go in this situation is to align the lists better. Can you perhaps points towards resources where this kind of restructuring is required for better flow, if any resources of that kind exist.