createMatrix | R Documentation |
Create a matrix by giving row and column names and with all elements being set to a default value
createMatrix(
rowNames,
colNames = rowNames,
value = 0,
name.row = NULL,
name.col = NULL
)
rowNames |
character vector of row names to be given to the matrix |
colNames |
character vector of column names to be given to the matrix |
value |
value to be given to each matrix element |
name.row |
optional. Name to be given to the row dimension |
name.col |
optional. Name to be given to the column dimension |
matrix with rowNames
as row names and colNames
as
column names, filled with value at each position
## Initialise a matrix with rows A to E and columns x to z of value -1
createMatrix(c("A", "B", "C", "D", "E"), c("x", "y", "z"), -1)
## By default the column names are assumed to be equal to the row names
createMatrix(c("A", "B", "C"))
## Initialise a square matrix with NA
createMatrix(c("A", "B", "C"), value = NA)
## Give a name to the row dimension
createMatrix(c("A", "B", "C"), name.row = "Letters")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.