I'm attempting to flatten a vector that contains a number of lists. What would be the best way to do that while retaining the data associated with that list? I tried using unlist but that gave me a list that was unconnected to my data.
## My data set looks something like this:
df <- data.frame(A = c(1,2,3),
                 B = c(3,5,4),
                 C = c(4,3,5),
                 D = c(7,9,2))
df$E <- list(c(5, 3, 2, 1), 5, c(5, 2, 1))
df
##  A B C D          E
## 1 1 3 4 7 5, 3, 2, 1
## 2 2 5 3 9          5
## 3 3 4 5 2    5, 2, 1
## Ideally I would like it to look like this:
 A B C D E
1 1 3 4 7 5 
2 1 3 4 7 3
3 1 3 4 7 2
4 1 3 4 7 1
5 2 5 3 9 5
6 3 4 5 2 5,
7 3 4 5 2 5 
8 3 4 5 2 2
9 3 4 5 2 1
Is there a simple way to do that?
 
     
     
    