as_matrix | R Documentation |
Convert dgCMatrix into a dense matrix
as_matrix(x, parallel = FALSE, sparse = FALSE)
x |
A matrix. |
parallel |
Logical value, default is |
sparse |
Logical value, default is |
dims_i <- 2000
dims_j <- 2000
sparse_matrix <- Matrix::sparseMatrix(
i = sample(1:dims_i, 500),
j = sample(1:dims_j, 500),
x = rnorm(500),
dims = c(dims_i, dims_j),
dimnames = list(
paste0("a", rep(1:dims_i)),
paste0("b", rep(1:dims_j))
)
)
system.time(as.matrix(sparse_matrix))
system.time(as_matrix(sparse_matrix))
system.time(as_matrix(sparse_matrix, parallel = TRUE))
identical(
as.matrix(sparse_matrix),
as_matrix(sparse_matrix)
)
identical(
as.matrix(sparse_matrix),
as_matrix(sparse_matrix, parallel = TRUE)
)
identical(
sparse_matrix,
as_matrix(as.matrix(sparse_matrix), sparse = TRUE)
)
## Not run:
network_table_1 <- inferCSN(
as_matrix(example_matrix, sparse = TRUE)
)
network_table_2 <- inferCSN(
as(example_matrix, "sparseMatrix")
)
plot_scatter(
data.frame(
network_table_1$weight,
network_table_2$weight
),
legend_position = "none"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.