Description Usage Arguments Value Author(s) See Also Examples
Get indices of certain (e.g., diagonal) matrix elements. These elements can be in:
diag - diagonal;
offdiag - offdiagonal;
col - indicated columns;
row - indicated rows;
trilow - lower triangle (with or without diagonal);
triupp - upper triangle (with or without diagonal).
| 1 2 3 4 5 6 7 8 9 10 11 12 13 | which.in(type, x, ...)
which.in.diag(x)
which.in.offdiag(x)
which.in.col(x, col)
which.in.row(x, row)
which.in.trilow(x, diag = FALSE)
which.in.triupp(x, diag = FALSE)
 | 
| type | Either  | 
| x | A matrix or an object, which can be coerced to a marix. | 
| ... | Other appropriate parameters indicated below. | 
| col | An index/Indices of columns that contain elements of interest. | 
| row | An index/Indices of rows that contain elements of interest. | 
| diag | logical. Should the diagonal be included? | 
Indices of indicated elements of a matrix.
Vilmantas Gegzna
Other matrix operations in spMisc: 
corr_vec2mat(),
indMatrix(),
nTri2nDiag(),
revalueMatrix(),
sort_matrix_elements,
which.max.all(),
which.max.perRow()
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | m1 <- matrix(NA, 5, 5)
m1
 #>        [,1] [,2] [,3] [,4] [,5]
 #>  [1,]   NA   NA   NA   NA   NA
 #>  [2,]   NA   NA   NA   NA   NA
 #>  [3,]   NA   NA   NA   NA   NA
 #>  [4,]   NA   NA   NA   NA   NA
 #>  [5,]   NA   NA   NA   NA   NA
which.in.diag(m1)
 #>  [1]  1  7 13 19 25
m2 <- matrix(NA, 2, 5)
which.in.diag(m2)
 #>  [1]  1  4
#================================
 which.in(diag,    m1)
 which.in(offdiag, m1)
 which.in(col, m1, col = 2)
 which.in(row, m1, row = 2)
 which.in(trilow, m1)
 which.in(trilow, m1, diag = TRUE)
 which.in(triupp, m1)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.