Skip to contents

Retrieves data for one or more clinical trials from the ClinicalTrials.gov API based on their NCT ID(s).

Usage

ctg_get_nct(nct_ids, fields = NULL)

Arguments

nct_ids

A character vector of one or more NCT IDs (e.g., "NCT04000165") for the clinical trials to fetch.

fields

A character vector specifying the fields to retrieve. If NULL (default), all available fields are fetched. If specified, it must be a subset of the available fields.

Value

A tibble containing the clinical trial data with columns matching the requested fields.

Details

This function allows you to specify one or more NCT IDs and optionally select specific fields of interest. It fetches the relevant data and returns it as a tibble.

The function constructs a request for each NCT ID, specifying the desired fields. It uses a progress bar to show the progress of fetching data for multiple trials. The data is returned as a tibble with columns corresponding to the requested fields. If any fetches fail or if the API response contains columns not requested, warnings will be issued.

Ensure that the fields parameter contains valid field names as specified in the guide below. Invalid fields will result in an error.

Field Names Guide

The following are the available fields you can request from ClinicalTrials.gov: NCT Number, Study Title, Study URL, Acronym, Study Status, Brief Summary, Study Results, Conditions, Interventions, Primary Outcome Measures, Secondary Outcome Measures, Other Outcome Measures, Sponsor, Collaborators, Sex, Age, Phases, Enrollment, Funder Type, Study Type, Study Design, Other IDs, Start Date, Primary Completion Date, Completion Date, First Posted, Results First Posted, Last Update Posted, Locations, Study Documents

Examples

# Fetch data for a single NCT ID
trial_data <- ctg_get_nct("NCT04000165")
trial_data
#> # A tibble: 1 × 30
#>   `NCT Number` `Study Title`  `Study URL` Acronym `Study Status` `Brief Summary`
#>   <chr>        <chr>          <chr>       <chr>   <chr>          <chr>          
#> 1 NCT04000165  A Dose-Findin… https://cl… NA      COMPLETED      "Background:\n…
#> # ℹ 24 more variables: `Study Results` <chr>, Conditions <chr>,
#> #   Interventions <chr>, `Primary Outcome Measures` <chr>,
#> #   `Secondary Outcome Measures` <chr>, `Other Outcome Measures` <chr>,
#> #   Sponsor <chr>, Collaborators <chr>, Sex <chr>, Age <chr>, Phases <chr>,
#> #   Enrollment <chr>, `Funder Type` <chr>, `Study Type` <chr>,
#> #   `Study Design` <chr>, `Other IDs` <chr>, `Start Date` <chr>,
#> #   `Primary Completion Date` <chr>, `Completion Date` <chr>, …

# Fetch data for multiple NCT IDs
multiple_trials <- ctg_get_nct(c("NCT04000165", "NCT04002440"))
multiple_trials
#> # A tibble: 2 × 30
#>   `NCT Number` `Study Title`  `Study URL` Acronym `Study Status` `Brief Summary`
#>   <chr>        <chr>          <chr>       <chr>   <chr>          <chr>          
#> 1 NCT04000165  A Dose-Findin… https://cl… NA      COMPLETED      "Background:\n…
#> 2 NCT04002440  Directed Use … https://cl… DREAM-… ACTIVE_NOT_RE… "Among ambulat…
#> # ℹ 24 more variables: `Study Results` <chr>, Conditions <chr>,
#> #   Interventions <chr>, `Primary Outcome Measures` <chr>,
#> #   `Secondary Outcome Measures` <chr>, `Other Outcome Measures` <chr>,
#> #   Sponsor <chr>, Collaborators <chr>, Sex <chr>, Age <chr>, Phases <chr>,
#> #   Enrollment <chr>, `Funder Type` <chr>, `Study Type` <chr>,
#> #   `Study Design` <chr>, `Other IDs` <chr>, `Start Date` <chr>,
#> #   `Primary Completion Date` <chr>, `Completion Date` <chr>, …

# Fetch data for multiple NCT IDs with specific fields
specific_fields <- ctg_get_nct(
  c("NCT04000165", "NCT04002440"),
  fields = c("NCT Number", "Study Title", "Study Status")
)
specific_fields
#> # A tibble: 2 × 3
#>   `NCT Number` `Study Title`                                      `Study Status`
#>   <chr>        <chr>                                              <chr>         
#> 1 NCT04000165  A Dose-Finding Study of AG-348 in Sickle Cell Dis… COMPLETED     
#> 2 NCT04002440  Directed Use of REmote Patient Management System … ACTIVE_NOT_RE…