sparsematrix_from_matrix: Convert matrix to sparse matrix

Description Usage Arguments Value Examples

View source: R/03_sparsematrix_from_matrix.R

Description

Converts adjacency matrices (class "matrix") to a sparse matrices (class "dgCMatrix").

Usage

1

Arguments

adj_mat

Adjacency matrix.

Value

A sparse matrix of class dgCMatrix.

Examples

1
2
3
4
5
6
#make matrix
   my_matrix <- rep(0, 100)
   my_matrix[c(1, 11, 22, 33, 44, 54, 65, 76, 87, 97)] <- 1
   my_matrix <- matrix(data = my_matrix, nrow = 10, ncol = 10)
#convert to sparsematrix
   sparsematrix_from_matrix(adj_mat = my_matrix)

BrianAronson/birankr documentation built on July 13, 2020, 1:19 p.m.