ctrdata-package {ctrdata}R Documentation

ctrdata: get started, connect database and function overview


A package for aggregating and analysing information on and results from clinical trials, retrieved from public study registers

1 - Database connection

Package ctrdata retrieves trial information and stores it in a database collection, which has to be given as a connection object to parameter con for several ctrdata functions; this connection object is created in slightly different ways for the three supported database backends:

Database Connection object
MongoDB dbc <- nodbi::src_mongo(db = "my_db", collection = "my_coll")
SQLite dbc <- nodbi::src_sqlite(dbname = "my_db", collection = "my_coll")
PostgreSQL dbc <- nodbi::src_postgres(dbname = "my_db"); dbc[["collection"]] <- "my_coll"
DuckDB dbc <- nodbi::src_duckdb(dbname = "my_db", collection = "my_coll")

Use a connection object with a ctrdata function, for example: ctrdata::dbQueryHistory(con = dbc).

Any such connection object can also be used with other packages, for example mongolite::mongo() or: nodbi::docdb_query(src = dbc, key = dbc$collection, fields = '{"_id": 1}', query = '{"sponsors.lead_sponsor.agency_class": "Industry"}')

A demo database in package ctrdata can be used with: dbc <- nodbi::src_sqlite(dbname = system.file("extdata", "demo.sqlite", package = "ctrdata"), collection = "my_trials")

2 - Operate on a clinical trial register

ctrOpenSearchPagesInBrowser, ctrLoadQueryIntoDb (load trial records into database collection), ctrFindActiveSubstanceSynonyms; see ctrdata-registers for details on registers and how to search.

3 - Get a data frame from the database collection

dbFindFields (find names of fields of interest in trial records in a collection), dbGetFieldsIntoDf (create a data frame for fields of interest from collection), dbFindIdsUniqueTrials (de-duplicated identifiers of clinical trial records that can be used to subset a data frame).

4 - Operate on a data frame with trial information

dfTrials2Long (convert fields with nested elements into long format), dfName2Value (get values for variable(s) of interest), and dfMergeTwoVariablesRelevel.


Ralf Herold ralf.herold@mailbox.org

[Package ctrdata version 1.11.1 Index]