Learn R Programming

redcapAPI (version 1.1)

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 file, as returned by exportRecords
factors
Logical. Determines if categorical data from REDCap are returned with their numeric codes, or as labelled factors.
dates
Logical. Determines if date variables from REDCap are converted to POSIXlt 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 leve
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.