Diagonal Matrix | R Documentation |
Fill the diagonal of a matrix or create a diagonal and initialize it with a specific value.
Diag.fill(x,v=0)
Diag.matrix(len,v=0)
x |
A matrix with data. |
len |
Number of columns or rows. |
v |
Value or vector to initialize the diagonal of a matrix.By default "v=0". |
Diag.fill returns a diagonal matrix where all the elements in the diagonal are equal to "v".
Diag.matrix returns a diagonal matrix where has dimension "len,len" and all the elements in the diagonal are equal to "v". It is fast for huge matrices with dimensions more than [row,col] = [500,500]
Manos Papadakis
R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.
rowMins, colFalse, nth, rowrange, rowMedians, rowVars, colSort, rowSort, colTrue
x <- matrix(rbinom(100*100,1,0.5),100,100)
f <- Diag.fill(x,1)
f <- Diag.fill(x,1:100) ##equals to diag(x)<-1:100
f <- Diag.matrix(100,1) ##equals to diag(1,100,100)
f <- Diag.matrix(100,1:100) ##equals to diag(1:100,100,100)
f<-x<-NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.