splitbyname is a utility function that splits the given vector based on the names of the components and returns a named list of arrays and vectors.

splitbyname(x)

Arguments

x

a vector or a list with the name attributes set

Value

A list of arrays and vectors. Missing entries in the arrays and vectors are filled in with NAs.

Details

The names are supposed to be of the format name[index], for example alpha[1,1], beta[1], etc.

A name without brackets is equivalent to a name with [1].

The dimension attribute will not be set in case of vectors.

Author

Jouni Kerman jouni@kerman.com

Examples


  x <- structure(c(1,3), names=c("x[1,1]", "x[3,3]"))
  splitbyname(x) # yields a list containing a 3x3 matrix
#> $x
#>       mean sd 1% 2.5% 25% 50% 75% 97.5% 99% NA. sims
#> [1,1]    1  0  1    1   1   1   1     1   1   0    1
#> [2,1]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [3,1]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [1,2]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [2,2]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [3,2]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [1,3]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [2,3]  NaN  0 NA   NA  NA  NA  NA    NA  NA 100    1
#> [3,3]    3  0  3    3   3   3   3     3   3   0    1
#>