demomat {lazy.tools} | R Documentation |
This can create either symbobic or numeric matrices.
demomat(nr, nc, n3 = 0, root = NULL, vec = 0, shape = NULL, nodiag = 0, supermat = 0, list = 0, mul = NULL, mul3 = NULL, rnroot = "r", cnroot = "c", anroot = "a")
nr |
# of rows of the matrix to be generated or a vector consisting of the # of rows of each submatrix. |
nc |
# of columns of the matrix to be generated or a vector consisting of the # of columns of each submatrix. |
n3 |
# of the 3d dimension, if any |
root |
The root character of symbolic matrix. |
vec |
= 1 to drop the redundant subscript. |
shape |
Shape of the resulting matrix: |
nodiag |
= 1 to set the diagonal elements to 0 when either "upper" or "lower" is specified |
supermat |
= 1 to create horizontally stacked array |
list |
= 1 to return the array as list |
mul |
See below. |
mul3 |
See below. |
rnroot |
root of the row names |
cnroot |
root of the column names |
anroot |
root of the third dimension names |
The i,j elements of a matrix will be named as mul*i + j
The i,j,k elements of an array will be named as mul3*(mul*i + j) + k
When a supermatrix is generated, SMdim attributes will be set
where SMdim is a list of the form \ce
(nrows=nr, ncols=nc, rownames=rn, colnames=cn, anames=an)
where
nr is a vector consisting of the number of rows of each submatrix,
nc is a vector consisting of the number of columns of each submatrix
rn is a vector consisting of the supplemental row names
cn is a vector consisting of the supplemental column names
an is a vector consisting of the names associated with the 3rd dim.
'
A matrix or an array.
Note that even with vec=1 option, thre result is a matrix.
Use c() to convert it to a vector.
demomat( 11,3 ) # numeric matrix demomat( 11,3,root="a" ) # symbolic matrix demomat( 4,1,root="a", vec=1 ) # symbolic matrix demomat( 4,3,2 ) # numeric array demomat( 4,3,2, supermat=1 ) # numeric supermatrix (horizontally stacked) demomat( 4,3,2, supermat=2 ) # numeric supermatrix (vertically stacked) demomat( c(4,3),c(3,2) ) # numeric supermatrix