Learn R Programming

ctrdata (version 1.16.0)

dbFindFields: Find names of fields in the database collection

Description

Given part of the name of a field of interest to the user, this function returns the full field names used in records that were previously loaded into a collection (using ctrLoadQueryIntoDb). The field names can be fed into function dbGetFieldsIntoDf to extract the data from the collection into a data frame.

Usage

dbFindFields(namepart = "", con, verbose = FALSE)

Value

Vector of strings with full names of field(s) found, ordered by register and alphabet. Names of the vector elements are the register names for the respective fields.

Only names of fields that have a value in the collection are returned, and the names may be incomplete because they are from sampled records. See here for obtaining a complete set of field names (albeit without register names): https://github.com/rfhb/ctrdata/issues/26#issuecomment-1751452462

Arguments

namepart

A character string (can include a regular expression, including Perl-style) to be searched among all field names (keys) in the collection, case-insensitive. Use ".*" to find all fields.

con

A connection object, see section `Databases` in ctrdata.

verbose

If TRUE, prints additional information (default FALSE).

Details

In addition to the full names of all child fields (e.g., clinical_results.outcome_list.outcome.measure.class_list.class.title) this function may return names of parent fields (e.g., clinical_results). Data in parent fields is typically complex (nested) and can be converted into individual data elements with dfTrials2Long, and subelements can then be accessed with dfName2Value. For field definitions of the registers, see row "Definition" in ctrdata-registers. Note: Only when dbFindFields is first called after ctrLoadQueryIntoDb, it will take a moment.

Examples

Run this code

dbc <- nodbi::src_sqlite(
    dbname = system.file("extdata", "demo.sqlite", package = "ctrdata"),
    collection = "my_trials"
)

dbFindFields(namepart = "date", con = dbc)

Run the code above in your browser using DataLab