Skip to content

Commit

Permalink
feat: update createDBMatrix() to use dplyr::copy_to()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed2uiz committed Jan 23, 2024
1 parent 78c8820 commit ee94247
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions R/dbMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit ee94247

Please sign in to comment.