I have two data frames below:
c1a <- c("1a","1a","1a")
c1b <- c("1b","1b","1b")
c2a <- c("2a","2a","2a")
c2b <- c("2b","2b","2b")
c3a <- c("3a","3a","3a")
c3b <- c("3b","3b","3b")
df1 <- as.data.frame(rbind(c1a,c2a,c3a))
df2 <- as.data.frame(rbind(c1b,c2b,c3b))
I want to create an array with three 2*3 matrices, each matrix gets its first row from df1, and its 2nd row from df2. something like,
, , 1
[,1] [,2] [,3]
[1,] 1a 1a 1a
[2,] 1b 1b 1b
, , 2
[,1] [,2] [,3]
[1,] 2a 2a 2a
[2,] 2b 2b 2b
, , 3
[,1] [,2] [,3]
[1,] 3a 3a 3a
[2,] 3b 3b 3b
array(c(rbind(c1a,c2a),rbind(c1b,c2b)), dim = c(2,3,2))
I am not sure how to get this for all rows of dataframes.