
Transform a list of array with the same structure in a array.
list_to_array.RdTransform a list of array with the same structure in a array.
Author
Frédéric Grelot, frederic.grelot.1994_cran@m4x.org
Examples
dim_a = c(3, 3)
dimnames_a = setNames(
lapply(dim_a, function(x){letters[seq(x)]}),
sprintf("dim_%s", letters[seq_along(dim_a)])
)
a = array(as.numeric(1), dim = dim_a, dimnames = dimnames_a)
l = list(a1 = a, a2 = 2 * a)
list_to_array(l)
#> , , state = a1
#>
#> dim_b
#> dim_a a b c
#> a 1 1 1
#> b 1 1 1
#> c 1 1 1
#>
#> , , state = a2
#>
#> dim_b
#> dim_a a b c
#> a 2 2 2
#> b 2 2 2
#> c 2 2 2
#>
list_to_array(l, what = "other")
#> , , other = a1
#>
#> dim_b
#> dim_a a b c
#> a 1 1 1
#> b 1 1 1
#> c 1 1 1
#>
#> , , other = a2
#>
#> dim_b
#> dim_a a b c
#> a 2 2 2
#> b 2 2 2
#> c 2 2 2
#>