Learn R Programming

REDCapExporter (version 0.3.0)

col_type: Column Types

Description

Define a type for each column of the records for a REDCap project based on the metadata for the project.

Usage

col_type(
  x,
  factors = TRUE,
  lubridate_args = list(quiet = TRUE, tz = NULL, locale = Sys.getlocale("LC_TIME"),
    truncated = 0),
  ...
)

Value

a rcer_col_type object

Arguments

x

a rcer_metadata or rcer_raw_metadata object

factors

If TRUE (default) then variables reported via drop-down lists and radio buttons are set up to be factors. If FALSE, then the column type will be character.

lubridate_args

a list of arguments passed to the date and time parsing calls. See Details.

...

not currently used

Details

REDCap text fields for dates and times are formatted via lubridate

REDCaplubridate parsing function
-----------------------------------------------
date_mdymdy
date_dmydmy
date_ymdymd
datetime_dmydmy_hm
datetime_mdymdy_hm
datetime_ymdymd_hm
datetime_seconds_dmydmy_hms
datetime_seconds_mdymdy_hms
datetime_seconds_ymdymd_hms
timehm
time_mm_ssms

Other text files are coerced as

REDCapR coercion
-----------------------------------------------
numberas.numeric
number_1dpas.numeric
number_2dpas.numeric
integeras.integer
..default..as.character

Variables inputted into REDCap via radio button or dropdown lists (multiple choice - pick one) are coerced to factors by default but can be returned as characters if the argument factors = FALSE is set.

Calculated and slider (visual analog scale) variables are coerced via as.numeric.

Yes/No and True/False variables are include as integer values 0 = No or False, and 1 for Yes or True.

Checkboxes are the most difficult to work with between the metadata and records. A checkbox field_name in the metadata could be, for example, "eg_checkbox" and the columns in the records will be "eg_checkbox___<code>" were "code" could be numbers, or character strings. REDCapExporter attempts to coerce the "eg_checkbox___<code>" columns to integer values, 0 = unchecked and 1 = checked.

Examples

Run this code

data("avs_raw_metadata")
col_type(avs_raw_metadata)

Run the code above in your browser using DataLab