I have a nested list current_output that I would like to unlist and obtain the expected output. I would like to assign the name of the list in current_output to it's sub-components. For example, I would like to assign the name A to the three sub-components in current_output, and similarly for B and C to match those in the `expected.
A1 <- c(1:3)
A2 <- c(4:6)
A3 <- c(7:9)
B1 <- c(1:2)
B2 <- c(3:4)
B3 <- 1
C1 <- c(1:3)
C2 <- 1
C3 <- 1
l1 <- list(list(A1), list(A2), list(A3))
l2 <- list(list(B1),list(B2), list(1))
l3 <- list(list(C1), list(1), list(1))
current_output <- list(l1, l2, l3)
names(current_output) <- c("A", "B", "C")
expected <- list(A1, A2, A3, B1, B2, B3, C1, C2, C3)
names(expected) <- c(rep("A", 3), rep("B", 3), rep("C", 3))