as_dgCMatrix | R Documentation |
dgCMatrix
(sparse matrix)This helper function allows easy coercion to sparse matrix objects
from the Matrix package, dgCMatrix
.
as_dgCMatrix(x, make.dimnames = TRUE, ...)
as.dgCMatrix(x, make.dimnames = TRUE, ...)
as_spmat(x, make.dimnames = TRUE, ...)
## Default S3 method:
as_dgCMatrix(x, make.dimnames = TRUE, ...)
## S3 method for class 'diffnet'
as_dgCMatrix(x, make.dimnames = TRUE, ...)
## S3 method for class 'array'
as_dgCMatrix(x, make.dimnames = TRUE, ...)
## S3 method for class 'igraph'
as_dgCMatrix(x, make.dimnames = TRUE, ...)
## S3 method for class 'network'
as_dgCMatrix(x, make.dimnames = TRUE, ...)
## S3 method for class 'list'
as_dgCMatrix(x, make.dimnames = TRUE, ...)
x |
An object to be coerced into a sparse matrix. |
make.dimnames |
Logical scalar. When |
... |
Further arguments passed to the method. |
In the case of the igraph
and network
methods, ...
is passed to
as_adj
and as.matrix.network
respectively.
Either a list with dgCMatrix
objects or a dgCMatrix
object.
set.seed(1231)
x <- rgraph_er(10)
# From matrix object
as_dgCMatrix(as.matrix(x))
# From a network object
as_dgCMatrix(network::as.network(as.matrix(x)))
# From igraph object
as_dgCMatrix(igraph::graph_from_adjacency_matrix(x))
# From array
myarray <- array(dim=c(10,10,2))
myarray[,,1] <- as.matrix(x)
myarray[,,2] <- as.matrix(x)
myarray
as_dgCMatrix(myarray)
# From a diffnet object
ans <- as_dgCMatrix(medInnovationsDiffNet)
str(ans)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.