Skip to contents

Converts in-memory matrix, Matrix::dgeMatrix, or Matrix::dgCMatrix into a dbMatrix object.

Generic function to convert in-memory objects to dbMatrix objects.

Usage

as.dbMatrix(x, con = NULL, name = "dbMatrix", overwrite = FALSE, ...)

as.dbMatrix(x, con = NULL, name = "dbMatrix", overwrite = FALSE, ...)

Arguments

x

Object to convert (e.g., matrix, dgCMatrix)

con

DBI or duckdb connection object

name

Table name to assign within database

overwrite

Whether to overwrite if table already exists

...

Additional arguments passed to methods

Value

A dbDenseMatrix for dense matrix inputs or a dbSparseMatrix for sparse matrix inputs. The returned object keeps the input dimensions and dimnames while storing matrix values in DuckDB.

Details

If no con is provided, a temporary in-memory database connection is created. If no name is provided, a unique table name is generated.