Learn R Programming

wizaRdry (version 0.6.4)

redcap.rune: Parse composite REDCap instrument into component data frames by variable prefix

Description

This function fetches a REDCap instrument and separates it into individual data frames for each survey/collection detected in the data based on column name prefixes. It identifies the appropriate identifier column and splits the data accordingly.

Usage

redcap.rune(
  instrument_name,
  prefix = NULL,
  raw_or_label = "raw",
  redcap_event_name = NULL,
  batch_size = 1000,
  records = NULL,
  fields = NULL,
  pii = FALSE,
  interview_date = NULL,
  date_format = "ymd",
  lower = TRUE
)

Value

If prefix is specified, returns a single dataframe with that prefix. Otherwise, creates multiple dataframes in the parent environment, one for each survey detected in the data. Each dataframe is named after its survey prefix.

Arguments

instrument_name

Name of the REDCap instrument

prefix

Character string; default NULL, if specified returns only the dataframe with this prefix

raw_or_label

Whether to return raw or labeled values

redcap_event_name

Optional event name filter. Can be a single string or a vector of event names (e.g., c("event1", "event2"))

batch_size

Number of records to retrieve per batch

records

Optional vector of specific record IDs

fields

Optional vector of specific fields

pii

Logical; if FALSE (default), remove fields marked as PII. TRUE keeps PII.

interview_date

Optional; date filtering parameter

date_format

Default ymd define date format for interview_date

lower

default TRUE convert prefixes to lower case

Examples

Run this code
if (FALSE) {
# Parse a REDCap instrument into its component dataframes
redcap.rune("baseline_assessment")

# After running, access individual survey dataframes directly:
head(pss)  # Access the PSS survey dataframe
head(cesd) # Access the CESD survey dataframe

# Parse a single survey from composite instrument
rgpts <- redcap.rune("baseline_assessment", prefix = "rgpts")
}

Run the code above in your browser using DataLab