constant: Collection of REDCap-specific constants

View source: R/constant.R

constantR Documentation

Collection of REDCap-specific constants

Description

Collection of constants defined by the REDCap developers.

Usage

constant(name)

Arguments

name

Name of constant. Required character.

Details

Form Completeness

The current constants relate to the 'complete' variable at the end of each form.

  • form_incomplete: 0L (i.e., an integer)

  • form_unverified: 1L

  • form_complete: 2L

Export Rights

See https://your-server/redcap/api/help/?content=exp_users.

  • data_export_rights_no_access : 0L

  • data_export_rights_deidentified : 1L

  • data_export_rights_full : 2L

Form Rights

See https://your-server/redcap/api/help/?content=exp_users. The order of these digits may be unexpected.

  • form_rights_no_access : 0L

  • form_rights_readonly : 2L

  • form_rights_edit_form : 1L

  • form_rights_edit_survey : 3L

Access Rights

See https://your-server/redcap/api/help/?content=exp_users.

  • access_no : 0L

  • access_yes : 1L

To add more, please for and edit constant.R on GitHub and submit a pull request. For instructions, please see Editing files in another user's repository # nolint in the GitHub documentation.

Value

The constant's value. Currently all are single integers, but that could be expanded in the future.

Author(s)

Will Beasley

Examples

REDCapR::constant("form_incomplete")  # Returns 0L
REDCapR::constant("form_unverified")  # Returns 1L
REDCapR::constant("form_complete"  )  # Returns 2L

REDCapR::constant("data_export_rights_no_access"   )  # Returns 0L
REDCapR::constant("data_export_rights_deidentified")  # Returns 1L
REDCapR::constant("data_export_rights_full"        )  # Returns 2L

REDCapR::constant("form_rights_no_access")   # Returns 0L
REDCapR::constant("form_rights_readonly" )   # Returns 2L --Notice the order
REDCapR::constant("form_rights_edit_form")   # Returns 1L
REDCapR::constant("form_rights_edit_survey") # Returns 3L

REDCapR::constant("access_no" )  # Returns 0L
REDCapR::constant("access_yes")  # Returns 1L

REDCapR::constant(c(
  "form_complete",
  "form_complete",
  "form_incomplete"
)) # Returns c(2L, 2L, 0L)
REDCapR::constant(c(
  "form_rights_no_access",
  "form_rights_readonly",
  "form_rights_edit_form",
  "form_rights_edit_survey"
)) # Returns c(0L, 2L, 1L, 3L)


constant_to_form_completion( c(0, 2, 1, 2, NA))
constant_to_form_rights(     c(0, 2, 1, 2, NA))
constant_to_export_rights(   c(0, 2, 1, 3, NA))
constant_to_access(          c(0, 1, 1, 0, NA))

## Not run: 
# The following line returns an error:
#     Assertion on 'name' failed: Must be a subset of
#     {'form_complete','form_incomplete','form_unverified'},
#     but is {'bad-name'}.

REDCapR::constant("bad-name")    # Returns an error

REDCapR::constant(c("form_complete", "bad-name")) # Returns an error

## End(Not run)

REDCapR documentation built on Aug. 10, 2022, 5:06 p.m.