# Arrange a multi-level list to a one-level list Classic List Threaded 3 messages Open this post in threaded view
|

## Arrange a multi-level list to a one-level list

 Dear all, I just want to arrange a multi-level list to a one-level list. For example: x <- list(list(matrix(sample(c(0,1), 4, replace = T), 2), matrix(sample(c(2,3), 4, replace = T), 2)), list(matrix(sample(c(0,1), 6, replace = T), 2), matrix(sample(c(2,3), 6, replace = T), 2))) > x [] [][]      [,1] [,2] [1,]    1    1 [2,]    0    0 [][]      [,1] [,2] [1,]    3    2 [2,]    3    3 [] [][]      [,1] [,2] [,3] [1,]    1    0    0 [2,]    0    1    0 [][]      [,1] [,2] [,3] [1,]    2    3    3 [2,]    3    3    3 If I do this work one time, I will arrange it like this:   c(x[], x[]) # Only consider the first level of the list. []      [,1] [,2] [1,]    1    1 [2,]    0    0 []      [,1] [,2] [1,]    3    2 [2,]    3    3 []      [,1] [,2] [,3] [1,]    1    0    0 [2,]    0    1    0 []      [,1] [,2] [,3] [1,]    2    3    3 [2,]    3    3    3 But when I repeat this work many times and the levels will change each time in a loop, how can I pass the arguments to c()? For example, in the first iteration, the first level of a list is 3, in the second iteration, the first level of a list is 5? …. Any help would be greatly appreciated. Lisa