dense2sparse: Converts matrix given in dense format to sparse format data...

Description Usage Arguments Value Examples

Description

This function only keeps non-zero cells. In case given dense matix is symmetric dense2sparse will return upper triangular part of the matrix (i.e. where rows <= columns)

Usage

1
dense2sparse(mtx, add.diagonal = TRUE, name = NULL)

Arguments

mtx

matrix in dense format

add.diagonal

logical, if true an additional column indicating diagonal of each cell will be appended to resulting data frame

name

character, additional argument, if specified column with name will be appended to resulting data frame

Value

data.frame with columns c("i","j","val") and optionally c("diagonal","name") columns; every row of resulting dataframe corresponds to cell in given dense matrix with i-th row, j-th column and value val

Examples

1
2
3
4
5
6
7
dense2sparse(matrix(1:24, ncol = 3))
dense2sparse(matrix(1:24, ncol = 3), name = "some.matrix")
dense2sparse(matrix(1:24, ncol = 3), add.diagonal = FALSE)
# symmetric matrix
mtx.sym <- matrix(1:25, ncol = 5)
mtx.sym <- mtx.sym + t(mtx.sym)
dense2sparse(matrix(mtx.sym))

rz6/CopulaHiC documentation built on Dec. 31, 2019, 9:19 a.m.