matrixNew | R Documentation |
Generate random/diagonal/zeros/ones matrix, the default is 3 by 3 matrix of 0.
matrixNew(
m = 3,
n = NULL,
x = 0,
diagonal = FALSE,
distr = NULL,
dimnames = NULL
)
m |
Number of rows. |
n |
Number of columns. If n = NULL, then n = m. |
x |
The value filling in the matrix . |
diagonal |
Logical, only diagonal remains if TRUE |
distr |
Distribution functions, e.g. rnorm, rt, runif, etc. If distr is provided, then x will be masked. |
dimnames |
A dimnames attribute for the matrix: NULL or a list of length 2 giving the row and column names, respectively. |
A random/diagonal/zeros/ones Matrix.
matrixRep
{
## Not run:
# The zeros/ones matrix
matrixNew(4) # zeros of 4 by 4 matrix
matrixNew(4, 5) # 4 by 5
matrixNew(x = 1) # ones of 3 by 3 matrix
# The eye/diagonal matrix
matrixNew(m = 3, x = 1, diagonal = TRUE)
matrixNew(m = 5, n = 3, x = 1, diagonal = TRUE)
matrixNew(m = 3, x = 4, diagonal = TRUE)
# The random matrix
matrixNew(m = 4, n = 5, distr = rnorm, dimnames = list(letters[1:4], letters[1:5]))
matrixNew(m = 4, n = 5, distr = rnorm, diagonal = TRUE)
## End(Not run)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.