validate_var_name: Validate That a String Conforms to Naming Standards

View source: R/R03-REDCap.R

validate_var_nameR Documentation

Validate That a String Conforms to Naming Standards

Description

Validate a string conforms to the Center for Addiction Medicine (CAM) R data-frame column naming standard. The CAM name standard is GGG.TTT.Optional.Var_name. This function maintains the ability to check if TTT conforms to the standard for R types or for REDCap field types and is vectorized over the input.

Usage

validate_var_name(str, type = "R")

Arguments

str

A string vector of names to validate.

type

A string of either "REDCap" or "R" to indicate how the type section of the name should be validated.

Details

The CAM Name Standard: GGG.TTT.Optional.Var_name.

  • GGG is the variable's group, which roughly corresponds to data of a similar nature or type. Examples include: IDS for identification variables, SBJ for subject demographic variables, SSS for important study details, INV for inventory measures, etc.

  • TTT is the variable's type, which corresponds to either a specific R type or a specific REDCap field type. Find permissible types below:

    • Possible R Types:

      • INT: An integer value.

      • DBL: A double or non-integer numeric value.

      • CHR: A character string.

      • DAT: A date-time value. TODO: Decide on exact date-time object.

      • LGC: A boolean value.

    • Possible REDCap Types:

      • DAT: Date-time fields.

      • INT: Integer fields.

      • DBL: Decimal/non-integer numeric fields.

      • CHR: All other text or notes box fields.

      • MCQ: Multiple choice drop-down lists and radio buttons.

      • CKB: Checkbox fields.

      • YNQ: Yes/No Questions.

      • FLE: Signature and file-upload fields.

      • VAS: Slider or visual analog scale (VAS) fields.

      • DSC: Descriptive text fields.

  • Optional: An optional, short, additional grouping identifier. This is most often indicated for inventories, to allow for additional grouping by the questionnaire/inventory itself. Multiple additional group identifier are allowed, so long as they maintain a period separator and contain only an alphanumeric sequence (i.e. no ⁠_⁠). Case should be sensible; this section should either be all caps (e.g. abbreviations) or only the first letter should be capitalized.

  • Var_name: A short, descriptive name for the field that would be appropriate for figure/table labeling. If the name consists of multiple words, the first word should be capitalized and subsequent words should be separated by ⁠_⁠ and appear in all lower-case. The one exception is if the entire word (e.g. an abbreviation) is capitalized.

Value

A boolean vector of equal length that specifies whether each element passed validation.

Author(s)

William Schmitt


rettopnivek/camrprojects documentation built on March 26, 2024, 9:17 a.m.