col_type: Column Types

View source: R/col-type.R

col_typeR Documentation

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),
  ...
)

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

REDCap lubridate parsing function
--------------------- --------------------------
date_mdy mdy
date_dmy dmy
date_ymd ymd
datetime_dmy dmy_hm
datetime_mdy mdy_hm
datetime_ymd ymd_hm
datetime_seconds_dmy dmy_hms
datetime_seconds_mdy mdy_hms
datetime_seconds_ymd ymd_hms
time hm
time_mm_ss ms

Other text files are coerced as

REDCap R coercion
--------------------- --------------------------
number as.numeric
number_1dp as.numeric
number_2dp as.numeric
integer as.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.

Value

a rcer_col_type object

Examples


data("avs_raw_metadata")
col_type(avs_raw_metadata)


REDCapExporter documentation built on April 4, 2025, 2:29 a.m.