Skip to contents

The function works with procotol- and results- related information. It converts lists and other values that are in a data frame returned by dbGetFieldsIntoDf into individual rows of a long data frame. From the resulting long data frame, values of interest can be selected using dfName2Value. The function is particularly useful for fields with complex content, such as node field "clinical_results" from EUCTR, for which dbGetFieldsIntoDf returns as a multiply nested list and for which this function then converts every observation of every (leaf) field into a row of its own.

Usage

dfTrials2Long(df)

Arguments

df

Data frame (or tibble) with columns including the trial identifier (_id) and one or more variables as obtained from dbGetFieldsIntoDf

Value

A data frame (or tibble, if tibble is loaded) with the four columns: `_id`, `identifier`, `name`, `value`

Examples


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

dfwide <- dbGetFieldsIntoDf(
  fields = "clinical_results.participant_flow",
  con = dbc)

dfTrials2Long(df = dfwide)
#> clinical_results.participant_flow.group_list.group                                                                                                                                                      

#> clinical_results.participant_flow.period_list.period.title                                                                                                                                              

#> clinical_results.participant_flow.period_list.period.milestone_list.milestone                                                                                                                           

#>                                                                                                                                                                                                         

#> . 
#> . 
#> . 
#> . 
#> . 
#> . 
#> . 
#> 
#> Total 22 rows, 7 unique names of variables
#>            _id identifier
#> 1  NCT02620761          1
#> 2  NCT02620761          2
#> 3  NCT02620761          1
#> 4  NCT02620761          2
#> 5  NCT02620761          1
#> 6  NCT02620761          2
#> 7  NCT02620761          0
#> 8  NCT02620761          1
#> 9  NCT02620761          2
#> 10 NCT02620761          3
#> 11 NCT02620761        1.1
#> 12 NCT02620761        1.2
#> 13 NCT02620761        1.1
#> 14 NCT02620761        1.2
#> 15 NCT02620761        2.1
#> 16 NCT02620761        2.2
#> 17 NCT02620761        2.1
#> 18 NCT02620761        2.2
#> 19 NCT02620761        3.1
#> 20 NCT02620761        3.2
#> 21 NCT02620761        3.1
#> 22 NCT02620761        3.2
#>                                                                                                                     name
#> 1                                                            clinical_results.participant_flow.group_list.group.group_id
#> 2                                                            clinical_results.participant_flow.group_list.group.group_id
#> 3                                                               clinical_results.participant_flow.group_list.group.title
#> 4                                                               clinical_results.participant_flow.group_list.group.title
#> 5                                                         clinical_results.participant_flow.group_list.group.description
#> 6                                                         clinical_results.participant_flow.group_list.group.description
#> 7                                                             clinical_results.participant_flow.period_list.period.title
#> 8                                    clinical_results.participant_flow.period_list.period.milestone_list.milestone.title
#> 9                                    clinical_results.participant_flow.period_list.period.milestone_list.milestone.title
#> 10                                   clinical_results.participant_flow.period_list.period.milestone_list.milestone.title
#> 11 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 12 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 13    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#> 14    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#> 15 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 16 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 17    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#> 18    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#> 19 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 20 clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.group_id
#> 21    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#> 22    clinical_results.participant_flow.period_list.period.milestone_list.milestone.participants_list.participants.count
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                value
#> 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                 P1
#> 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                 P2
#> 3                                                                                                                                                                                                                                                                                                                                                                                                                                                            Control
#> 4                                                                                                                                                                                                                                                                                                                                                                                                                                                         Fenoldopam
#> 5                                                          Infants in the Placebo arm will receive 0.9% sodium chloride (0.1 ml/hr). If, after 6 hrs there is not a clinically concerning decrease in blood pressure, as determined by attending physician, the rate of infusion (in this arm the placebo) will be increased to 0.2 ml/kg/hr. This rate will be continued throughout the remainder of the study.\r0.9%NS: Randomized to receive Fenoldopam or 0.9%NS
#> 6  Infants in the experimental arm will receive fenoldopam (60 ug/ml; 0.1 ml/hr to provide 0.1ug/kg/min). If, after 6 hrs there is not a clinically concerning decrease in blood pressure, as determined by attending physician, the rate of infusion will be increased to 0.2 ml/kg/hr (0.2 ug/kg/min for infants receiving fenoldopam). This rate will be continued throughout the remainder of the study.\rFenoldopam: Randomized to receive Fenoldopam or 0.9%NS
#> 7                                                                                                                                                                                                                                                                                                                                                                                                                                                      Overall Study
#> 8                                                                                                                                                                                                                                                                                                                                                                                                                                                            STARTED
#> 9                                                                                                                                                                                                                                                                                                                                                                                                                                                          COMPLETED
#> 10                                                                                                                                                                                                                                                                                                                                                                                                                                                     NOT COMPLETED
#> 11                                                                                                                                                                                                                                                                                                                                                                                                                                                                P1
#> 12                                                                                                                                                                                                                                                                                                                                                                                                                                                                P2
#> 13                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1
#> 14                                                                                                                                                                                                                                                                                                                                                                                                                                                                 0
#> 15                                                                                                                                                                                                                                                                                                                                                                                                                                                                P1
#> 16                                                                                                                                                                                                                                                                                                                                                                                                                                                                P2
#> 17                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1
#> 18                                                                                                                                                                                                                                                                                                                                                                                                                                                                 0
#> 19                                                                                                                                                                                                                                                                                                                                                                                                                                                                P1
#> 20                                                                                                                                                                                                                                                                                                                                                                                                                                                                P2
#> 21                                                                                                                                                                                                                                                                                                                                                                                                                                                                 0
#> 22                                                                                                                                                                                                                                                                                                                                                                                                                                                                 0