duckdb R package

Installation from CRAN


Installation from r-universe

install.packages("duckdb", repos = c("", ""))

Installation from GitHub

# install.packages("pak", repos = sprintf("", .Platform$pkgType, R.Version()$os, R.Version()$arch))

User Guide

See the R API in the DuckDB documentation.


To build the bleeding edge of duckdb-r, you can clone this repository and run

~duckdb-r: R CMD INSTALL .

If you wish to test new duckdb functionality with duckdb-r, make sure your clones of duckdb-r and duckdb share the same parent directory. Then run the following commands

~ (cd duckdb && git checkout {{desired_branch}})
~ (cd ducdkb-r && ./
~ (cd duckdb-r && R CMD INSTALL .)

It helps if both the duckdb directory and duckdb-r directory are clean. If you encounter linker errors, merge both duckdb-r and duckdb with their respective main branches.


To build the R package, you first need to install the dependencies:

# install.packages("pak", repos = sprintf("", .Platform$pkgType, R.Version()$os, R.Version()$arch))

Developing with Extensions

If you wish to build or add extensions to the R package you first need to build duckdb with the extension_static_build flag. The following commands allow you to add the httpfs extension to a DuckDB R build. See the extension ReadMe for more information about extensions

cd duckdb/

Then in R, run:

con <- DBI::dbConnect(duckdb(config=list('allow_unsigned_extensions'='true')))
dbExecute(con, "LOAD '{{path_to_duckdb}}/build/release/extension/httpfs/httpfs.duckdb_extension'")

For more information about using extensions, see the documentation on extensions. For instructions on building them, see extension README.