rc_format: Format records data

View source: R/rc_format.R

rc_formatR Documentation

Format records data

Description

Uses REDCap project metadata to format records data.

Usage

rc_format(
  record_data,
  data_dict = getOption("redcap_bundle")$data_dict,
  event_data = getOption("redcap_bundle")$event_data,
  factor_labels = TRUE,
  col_labels = TRUE,
  dates = TRUE,
  event_labels = TRUE,
  strip = FALSE
)

Arguments

record_data

Dataframe. Record data export from REDCap

data_dict

Dataframe. REDCap project data data_dictionary. By default, this will be fetched from the REDCap bundle option, as created by rc_bundle. Otherwise, a data.frame containing the project data dictionary must be supplied.

event_data

Dataframe. REDCap event data. By default, this will be fetched from the REDCap bundle option, as created by rc_bundle.

factor_labels

Logical. Determines whether categorical fields (eg radio, dropdown, checkbox) will be formatted as numeric codes or labels. Note that for checkbox fields, 0 (representing an unchecked box) will be replaced with NA.

col_labels

Logical. Determines if the field labels are applied to the dataframe columns.

dates

Logical. Determines if date variables are converted to POSIXct format during the download.

event_labels

Logical. Determines if event labels are applied to redcap_event_name column (Default = TRUE) or left as unique event names.

strip

Logical. If FALSE, empty rows and columns will be removed from record_data. See rc_strip for more information or call separately for more options.

Details

This function takes raw REDCap data and adds column labels, converts columns to numeric/character/factor as appropriate, and applies factor and checkbox labels. Formatting details of the returned dataframe can be found via attributes(record_data)$redcap_formatting.

Author(s)

Marcus Lehr

Benjamin Nutter


chillywings/rctools documentation built on Aug. 9, 2024, 11:52 p.m.