Convert Array to Data Frame
Usage
arrayToDataFrame(x, name = deparse(substitute(x)))
Value
data frame with as many rows as there are elements in the input array
x
. The data frame has one column per dimension of x
containing the dimension names and one additional column called according
to name
containing the array values.
Examples
x <- array(1:24, dim = c(2, 3, 4), dimnames = list(
c("a", "b"),
c("x", "y", "z"),
c("r", "s", "t", "u")
))
arrayToDataFrame(x)
#> Var1 Var2 Var3 x
#> 1 a x r 1
#> 2 b x r 2
#> 3 a y r 3
#> 4 b y r 4
#> 5 a z r 5
#> 6 b z r 6
#> 7 a x s 7
#> 8 b x s 8
#> 9 a y s 9
#> 10 b y s 10
#> 11 a z s 11
#> 12 b z s 12
#> 13 a x t 13
#> 14 b x t 14
#> 15 a y t 15
#> 16 b y t 16
#> 17 a z t 17
#> 18 b z t 18
#> 19 a x u 19
#> 20 b x u 20
#> 21 a y u 21
#> 22 b y u 22
#> 23 a z u 23
#> 24 b z u 24