Skip to contents

Get information for variable of interest (e.g., clinical endpoints) from a long data frame of protocol- or result-related trial information as returned by dfTrials2Long. Parameters valuename, wherename and wherevalue are matched using Perl regular expressions and ignoring case. See also ctrdata-trial-concepts for how to extract and calculate concepts of interest across registers.

Usage

dfName2Value(df, valuename = "", wherename = "", wherevalue = "")

Arguments

df

A data frame (or tibble) with four columns (_id, identifier, name, value) as returned by dfTrials2Long

valuename

A character string for the name of the field that holds the value of the variable of interest (e.g., a summary measure such as "endPoints.*tendencyValue.value")

wherename

(optional) A character string to identify the variable of interest among those that repeatedly occur in a trial record (e.g., "endPoints.endPoint.title")

wherevalue

(optional) A character string with the value of the variable identified by wherename (e.g., "response")

Value

A data frame (or tibble, if tibble is loaded) that includes the values of interest, with columns _id, identifier, name, value and where (with the contents of wherevalue found at wherename). Contents of value are strings unless all its elements are numbers. The identifier is generated by function dfTrials2Long to identify matching elements, e.g endpoint descriptions and measurements.

Examples


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

dfwide <- dbGetFieldsIntoDf(
    fields = c(
        ## ctgov - typical results fields
        # "clinical_results.baseline.analyzed_list.analyzed.count_list.count",
        # "clinical_results.baseline.group_list.group",
        # "clinical_results.baseline.analyzed_list.analyzed.units",
        "clinical_results.outcome_list.outcome",
        "study_design_info.allocation",
        ## euctr - typical results fields
        # "trialInformation.fullTitle",
        # "baselineCharacteristics.baselineReportingGroups.baselineReportingGroup",
        # "trialChanges.hasGlobalInterruptions",
        # "subjectAnalysisSets",
        # "adverseEvents.seriousAdverseEvents.seriousAdverseEvent",
        "endPoints.endPoint",
        "subjectDisposition.recruitmentDetails"
    ), con = dbc
)
#> Querying database (4 fields)...
#> Typing fields...

dflong <- dfTrials2Long(df = dfwide)
#> clinical_results.outcome_list.outcome                                                                                                                                                                   

#> study_design_info.allocation                                                                                                                                                                            

#> endPoints.endPoint                                                                                                                                                                                      

#> subjectDisposition.recruitmentDetails                                                                                                                                                                   

#>                                                                                                                                                                                                         

#> . 
#> . 
#> 
#> Total 8504 rows, 105 unique names of variables

## get values for the endpoint 'response'
dfName2Value(
    df = dflong,
    valuename = paste0(
        "clinical_results.*measurement.value|",
        "clinical_results.*outcome.measure.units|",
        "endPoints.endPoint.*tendencyValue.value|",
        "endPoints.endPoint.unit"
    ),
    wherename = paste0(
        "clinical_results.*outcome.measure.title|",
        "endPoints.endPoint.title"
    ),
    wherevalue = "response"
)
#> Returning values for 1 out of 6 trials
#> # A tibble: 63 × 5
#>    `_id`       identifier name                                             value
#>    <chr>       <chr>      <chr>                                            <chr>
#>  1 NCT03548584 7.1.1      clinical_results.outcome_list.outcome.measure.c… 11.3 
#>  2 NCT03548584 7.1.2      clinical_results.outcome_list.outcome.measure.c… 13.2 
#>  3 NCT03548584 7.2.1      clinical_results.outcome_list.outcome.measure.c… 29.3 
#>  4 NCT03548584 7.2.2      clinical_results.outcome_list.outcome.measure.c… 27.6 
#>  5 NCT03548584 7.3.1      clinical_results.outcome_list.outcome.measure.c… 43.1 
#>  6 NCT03548584 7.3.2      clinical_results.outcome_list.outcome.measure.c… 37.9 
#>  7 NCT03548584 7.4.1      clinical_results.outcome_list.outcome.measure.c… 59.6 
#>  8 NCT03548584 7.4.2      clinical_results.outcome_list.outcome.measure.c… 38.8 
#>  9 NCT03548584 7.5.1      clinical_results.outcome_list.outcome.measure.c… 65.8 
#> 10 NCT03548584 7.5.2      clinical_results.outcome_list.outcome.measure.c… 45.7 
#> # ℹ 53 more rows
#> # ℹ 1 more variable: where <chr>