expandmatrix reshapes a matrix of values into a 3 column data.frame
expandmatrix.Rd
expandmatrix takes an oblong matrix of values and expands it into a three column data.frame of row, column, value. This is then easier to plot as a scattergram or is used within categoryplot. It expects to have the year values in the columns = xvalues
Examples
x <- matrix(rnorm(25,5,1),nrow=5,ncol=5,dimnames=list(1:5,1:5))
res <- expandmatrix(x)
res
#> rows cols value
#> 1_1 1 1 7.178787
#> 1_2 1 2 3.285575
#> 1_3 1 3 5.104090
#> 1_4 1 4 5.857074
#> 1_5 1 5 6.401611
#> 2_1 2 1 4.327800
#> 2_2 2 2 6.325946
#> 2_3 2 3 4.613215
#> 2_4 2 4 5.093921
#> 2_5 2 5 5.634319
#> 3_1 3 1 4.449196
#> 3_2 3 2 4.007122
#> 3_3 3 3 5.195118
#> 3_4 3 4 4.354096
#> 3_5 3 5 5.968469
#> 4_1 4 1 5.028417
#> 4_2 4 2 4.956657
#> 4_3 4 3 4.444125
#> 4_4 4 4 3.674754
#> 4_5 4 5 4.462788
#> 5_1 5 1 3.408312
#> 5_2 5 2 7.582301
#> 5_3 5 3 7.062632
#> 5_4 5 4 5.200929
#> 5_5 5 5 6.002982