Git Product home page Git Product logo

redcaptools's Introduction

redcaptools

R-CMD-check

redcaptools contains home-grown functions for working with REDCap data in R.

Installation

You can install the development version of redcaptools from github with:

remotes::install_github("CTU-Bern/redcaptools")

Or from CTU Bern’s package universe

install.packages("redcaptools", repos = c('https://ctu-bern.r-universe.dev', 'https://cloud.r-project.org'))

Export data from REDCap

REDCap offers (at least) two approaches for exporting a projects data - throught the web interface via clicking buttons, and the API, which allows programmatic access to a lot more information than is available through the web interface. In order to use the API, a token is required. The API token can be requested from the projects API page, accessible from the link in the applications section of the menu on the left side of the page.

If you do not see that link, consult with whoever is in charge of user management for the project to give you access to it.

Once you have access, you can request a token, which a system administrator must approve. Once approved, the token is shown on the API page. Now you have everything to download data through the API. Because your token is essentially your username, password and a reference to a specific project, extra care must be taken with it. The httr package has a vignette on managing secrets, which is relevant to the API token.

The standard download can be replicated via

# the URL ir the same as the website just with '/api/' on the end
url <- "https://redcap.domain.something/api/"
token <- readLines("path-to-file-containing-token") # or some other method
d <- redcap_export_tbl(token, url, "record")

More interesting is the redcap_export_byform function, which returns a list of dataframes, where each element of the list is a specific eCRF from the database.

l <- redcap_export_byform(token, url)

Some of the available metadata stored in REDCap is available via the redcap_export_meta function, including the data dictionary, which can also be downloaded via the website.

m <- redcap_export_meta(token, url)

Once you have the data and metadata, the redcap_prep function can be used to reformat the data - convert variables to date, POSIX, factors, etc as appropriate.

prepped <- redcap_prep(d, m$metadata)
prepped_list <- sapply(l, redcap_prep, metadata = m$metadata)

redcaptools's People

Contributors

aghaynes avatar dominikguentensperger avatar actions-user avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.