Vote count:
0
Using R... I have a list of tables.
# Example data
z <- list(cbind(c(1,2), c(3,4)), cbind(c(1,2), c(3,4,5,6)), cbind(c(1,2), c(1,2,3,4,5,6)), cbind(c(1,2), c(3,4)), cbind(c(1,2), c(3,4,5,6,9,4,5,6)))
z <- setNames(z, c("Ethnicity", "Country", "Age Band", "Marital Status", "Hair Color"))
z
$Ethnicity
[,1] [,2]
[1,] 1 3
[2,] 2 4
$Country
[,1] [,2]
[1,] 1 3
[2,] 2 4
[3,] 1 5
[4,] 2 6
$`Age Band`
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 1 3
[4,] 2 4
[5,] 1 5
[6,] 2 6
$`Marital Status`
[,1] [,2]
[1,] 1 3
[2,] 2 4
$`Hair Color`
[,1] [,2]
[1,] 1 3
[2,] 2 4
[3,] 1 5
[4,] 2 6
[5,] 1 9
[6,] 2 4
[7,] 1 5
[8,] 2 6
I would like to "collapse" (not sure if that is the right word) this list into one super table, as the column variables are the same for every table in the list. I would want the output to look something like that which I have written below... Is there any way to do this? I tried using do.call(rbind, z) but this didn't give me the proper output. Thanks!
Ethnicity
[1,] 1 3
[2,] 2 4
Country
[1,] 1 3
[2,] 2 4
[3,] 1 5
[4,] 2 6
`Age Band`
[1,] 1 1
[2,] 2 2
[3,] 1 3
[4,] 2 4
[5,] 1 5
[6,] 2 6
`Marital Status`
[1,] 1 3
[2,] 2 4
`Hair Color`
[1,] 1 3
[2,] 2 4
[3,] 1 5
[4,] 2 6
[5,] 1 9
[6,] 2 4
[7,] 1 5
[8,] 2 6
asked 29 secs ago
How to convert a list of tables into one big table in R
Aucun commentaire:
Enregistrer un commentaire