sparsematrix_from_matrix function

Convert matrix to sparse matrix

Convert matrix to sparse matrix

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

sparsematrix_from_matrix(adj_mat)

Arguments

  • adj_mat: Adjacency matrix.

Returns

A sparse matrix of class dgCMatrix.

Examples

#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)
  • Maintainer: Brian Aronson
  • License: MIT + file LICENSE
  • Last published: 2020-03-23

Useful links