Learn R Programming

redcapAPI (version 1.3)

fieldToVar: Convert a REDCap Data Field to an R Vector

Description

Converts a field exported from REDCap into a valid R vector

Usage

fieldToVar(m, d, factors = TRUE, dates = TRUE, checkboxLabels = FALSE,
  vname)

Arguments

m

a metadata file, as returned by exportMetaData

d

A data files, as returned by exportRecords

factors

Logical. Determines if categorical factors from REDCap are returned with their numeric codes or as labelled factors.

dates

Logical. Determines if date variables from REDCap are converted to POSIXct format. The API returns dates as character strings by default in YYYY-MM-DD format.

checkboxLabels

Logical. Determines the format of labels in checkbox variables. If FALSE labels are applies as "Unchecked"/"Checked". If TRUE, they are applied as ""/"[field_label]" where [field_label] is the label assigned to the level in the data dictionary. This option only applies when factors=TRUE and only to REDCap versions 6.0 and higher

vname

The variable name being converted. This is used only when checkboxLabels=TRUE in order to extract the checkbox label.

Details

This function is called internally by exportRecords and exportReports. it is not available to the user.