dbFindFields {ctrdata}R Documentation

Find names of fields in the database collection


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.


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



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.


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


If TRUE, prints additional information (default FALSE).


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.


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


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

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

[Package ctrdata version 1.16.0 Index]