I have a number of data.frames stored in a list (list1) and would like to create a new list (list2) with data.frames where the first contains all the first rows of the data.frames in list1, second contains all the second rows etc. Here is an example:
set.seed(42)
df1 <- data.frame(a=sample.int(100,3),b=sample.int(100,3))
df2 <- data.frame(a=sample.int(100,3),b=sample.int(100,3))
list1 <- list(df1,df2)
list1
[[1]]
a b
1 92 84
2 93 64
3 29 51
[[2]]
a b
1 74 71
2 14 46
3 65 100
From that I would like to create list 2 that should be as follows:
[[1]]
a b
1 92 84
2 74 71
[[2]]
a b
1 93 64
2 14 46
[[3]]
a b
1 29 51
2 65 100
What would be an efficient way to do this in R?