syncUnderscoreCodings: Sychronize coding of checkbox variables between meta data and...

Description Usage Arguments Details Author(s)

Description

Due to a bug in the REDCap export module, underscores in checkbox codings are not retained in the suffixes of the field names in the exported records. For example, if variable chk is a checkbox with a coding 'a_b, A and B', the field name in the data export becomes chk___ab. The loss of the underscore causes fieldToVar to fail as it can't match variable names to the meta data. syncUnderscoreCodings rectifies this problem by searching the suffixes and meta data for underscores. If a discrepancy is found, the underscores are removed from the metadata codings, restoring harmony to the universe. This bug was fixed in REDCap version 5.5.21 and this function does not apply to that and later versions.

Usage

1
syncUnderscoreCodings(records, meta_data, export = TRUE)

Arguments

records

The data frame object returned from the API export prior to applying factors, labels, and dates via the fieldToVar function.

meta_data

Metadata export from exportMetaData

export

Logical. Specifies if data are being synchronized for import or export

Details

syncUnderscoreCodings performs a series of evaluations. First, it determines if any underscores are found in the checkbox codings. If none are found, the function terminates without changing anything.

If the checkbox codings have underscores, the next evaluation is to determine if the variable names suffixes have matching underscores. If they do, then the function terminates with no changes to the meta data.

For data exports, if the prior two checks find underscores in the meta data and no underscores in the suffixes, the underscores are removed from the meta data and the new meta data returned.

For data imports, the meta data are not altered and the checkbox_field_name_map attribute is used to synchronize field names to the meta data and the expectations of REDCap (for import, REDCap expects the underscore codings to be used.

Author(s)

Benjamin Nutter



Search within the redcapAPI package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.