From ee94247a5a9d3292f6ec06917f81cc0a742eabbc Mon Sep 17 00:00:00 2001 From: Eddie Ruiz <32622519+Ed2uiz@users.noreply.github.com> Date: Tue, 23 Jan 2024 11:36:49 -0500 Subject: [PATCH] feat: update createDBMatrix() to use dplyr::copy_to() --- R/dbMatrix.R | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/R/dbMatrix.R b/R/dbMatrix.R index 2d6e8b1..70b72dc 100644 --- a/R/dbMatrix.R +++ b/R/dbMatrix.R @@ -327,14 +327,15 @@ createDBMatrix <- function(value, # data <- read_matrix(con = con, value = value, name = name, # overwrite = overwrite, ...) } else if(inherits(value, "matrix") | inherits(value, "Matrix")) { - # convert dense matrix to triplicate vector ijx format - ijx <- Matrix::summary(as(value, "TsparseMatrix")) |> as.data.frame() - - # write to db - DBI::dbWriteTable(conn = con, name = name, value = ijx, - overwrite = overwrite, ...) - - data <- dplyr::tbl(con, name) + # convert dense matrix to triplet vector ijx format + ijx <- as_ijx(value) + + # write ijx to db + data <- dplyr::copy_to(dest = con, + name = name, + df = ijx, + overwrite = overwrite, + temporary = FALSE) dims <- dim(value) dim_names <- list(rownames(value), colnames(value))