Here’s an R function that you can use to download clinical trial data

Sometimes you need to look at a lot of sets of clinical trial data, and you don’t want to go to and do searches manually, then save the files manually, then load them into R or Excel manually to get your work done.


get_ct_dot_gov_data_for_drugname <- function (drugname) {

   temp <- tempfile()

   download.file(paste0("", URLencode(drugname, reserved = TRUE), "&flds=a&flds=b&flds=y"), temp)

   trial_data <- read_delim(
     escape_double = FALSE,
     trim_ws = TRUE


   return (trial_data)


So here’s a function that you can use to download all the trials for a given drug name, and it returns a data frame with the trial metadata.


Published by

The Grey Literature

This is the personal blog of Benjamin Gregory Carlisle PhD. Queer; Academic; Queer academic. "I'm the research fairy, here to make your academic problems disappear!"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.