redcap_toform: Convert manually downloaded REDCap data into a list of forms

View source: R/redcap_toform.R

redcap_toformR Documentation

Convert manually downloaded REDCap data into a list of forms

Description

Similar to redcap_export_byform, this function tries to split a manually downloaded dataset into it's constituent forms. While use of the API allows individual forms to be downloaded, with a manual download, only the data dictionary is available as auxillary information. If no data dictionary is available, the function will use the variable names to guess the forms (see details).

Usage

redcap_toform(data, datadict = NULL, metadata = NULL, guess_events = TRUE, ...)

Arguments

data

imported REDCap data

datadict

data dictionary downloaded manually from REDCap

metadata

metadata downloaded from REDCap API

guess_events

restrict forms to events (rows) where data exists (see details)

...

additional arguments passed to other functions (currently unused)

Details

In a longitudinal data collection with many forms, a REDCap dataset will have a large degree of empty cells. The guess_events argument uses missingness as an indicator of a row not being part of the form in question. If all user variables (i.e. those that do not start with redcap) are empty, the row will be removed from the dataset.

If neither datadict nor metadata are provided, the function will attempt to guess the forms based on the variable names, specifically the form_complete variables which denote the state of the form. This is not a foolproof method: there may be other variables in the data that end with _complete.

Examples

data <- readRDS(system.file("extdata/test.rda", package = "redcaptools"))
metadata <- readRDS(system.file("extdata/meta.rda", package = "redcaptools"))
dd <- read.csv(system.file("extdata/DataDictionary.csv", package = "redcaptools"))
redcap_toform(data, dd)
redcap_toform(data, metadata = metadata)
redcap_toform(data)

aghaynes/redcaptools documentation built on April 5, 2025, 9:28 a.m.