# Install R package ctrdata

#### Ralf Herold

#### 2026-03-07

## Install package `ctrdata` on an R system

The R Project website (https://www.r-project.org/) provides installers for the R system. It can be used with software products and graphical user interfaces such as R Studio or from Visual Studio Code.

General information on the `ctrdata` package is available here: https://rfhb.github.io/ctrdata/.

In R, execute:

    install.packages("ctrdata")

For using the development version of package `ctrdata`, install from GitHub:

    # install package under development
    install.packages(c("remotes"))
    remotes::install_github("rfhb/ctrdata", dependencies = TRUE, build_vignettes = TRUE)

Either of the above should install package `ctrdata` into the user’s library.

## Databases to use

At this time, a PostgreSQL, DuckDB, an SQLite or a MongoDB (local or remote) database can be used with the package `ctrdata`. A full SQLite database is provided in the R package `RSQLite`. Suggested installation instructions for PostgreSQL are here and for a local MongoDB server are here; a remote MongoDB database server is accessible here. See here for a speed comparison of the databases; recommended: DuckDB, PostgreSQL or MongoDB local server.

Purpose | Function call
--- | ---
Create SQLite database connection | `dbc <- nodbi::src_sqlite(dbname = "name_of_my_database", collection = "name_of_my_collection")`
Create DuckDB database connection* | `dbc <- nodbi::src_duckdb(dbname = "name_of_my_database", collection = "name_of_my_collection")`
Create MongoDB database connection | `dbc <- nodbi::src_mongo(db = "name_of_my_database", collection = "name_of_my_collection")`
Create PostgreSQL database connection | `dbc <- nodbi::src_postgres(dbname = "name_of_my_database"); dbc[["collection"]] <- "name_of_my_collection"`
Use connection with `ctrdata` functions | `ctrdata::{ctrLoadQueryIntoDb, dbQueryHistory, dbFindIdsUniqueTrials, dbFindFields, dbGetFieldsIntoDf}(con = dbc, ...)`

- For DuckDB, the JSON extension is needed which can be permanently downloaded as follows:

    # user to specify their directory of choice;
    # remember to set option for each new R session
    options(duckdb.extension_directory = "~/.duckdb_extensions")

    # load and store in above-mentioned
    # directory; only once to be executed
    DBI::dbExecute(duckdb::dbConnect(duckdb::duckdb()), 'INSTALL json;')

## Attach package `ctrdata`

After completing the installation, attach the package from the user’s library:

    library(ctrdata)

## Credit to clinical trial registers

Remember to respect the registers’ terms and conditions (see `ctrOpenSearchPagesInBrowser(copyright = TRUE)`).

## Quote or reference `ctrdata`

In any publication, please cite this package as follows:

    ## Warning in citation(auto = meta): could not determine year for 'ctrdata' from
    ## package DESCRIPTION file

Herold R (2026). “Aggregating and analysing clinical trials data from multiple public registers using R package ctrdata.” Research Synthesis Methods, 17(3), 624–656. ISSN 1759-2879, 1759-2887. doi:10.1017/rsm.2025.10061 https://doi.org/10.1017/rsm.2025.10061. or
Herold R (????). ctrdata: Retrieve and Analyze Clinical Trials Data from Public Registers. R package version 1.26.2, https://cran.r-project.org/package=ctrdata.