Downloads data from REDCap by wrapping REDCapR::redcap_read()
. It handles
variable type conversion and creating factors from categorical variables. It
can optionally rename variables to adhere to Stata's variable naming rules.
Usage
bhhi_rc_read(
project_token_name,
convert_factors = TRUE,
for_stata = FALSE,
col_types = "auto",
export_survey_fields = TRUE,
verbose = FALSE,
...
)
Arguments
- project_token_name
Name of the project's REDCap API Token as stored by
bhhi_store_token()
in the operating system credential vault or an environment variable.- convert_factors
Automatically convert categorical variables to factors using the variable labels from the REDCap project. Default is TRUE.
- for_stata
Should the data be prepared for use in Stata? This makes sure variable names are legal Stata variable names. Default is FALSE.
- col_types
Controls the variable types when parsing the REDCap data. One of "auto", which uses the project metadata to assign variable types; "guess", which uses the
readr::col_guess()
to determine the column types; "string" which parses all variables as character strings; or a customreadr::cols()
specification. Default is "auto".- export_survey_fields
A boolean that specifies whether to export the survey identifier field (e.g., 'redcap_survey_identifier') or survey timestamp fields (e.g., instrument+'_timestamp'). The timestamp outputs reflect the survey's completion time (according to the time and timezone of the REDCap server.)
- verbose
Should messages be printed to the R console during the operation. The verbose output might contain sensitive information (e.g. PHI), so turn this off if the output might be visible somewhere public.
- ...
Options passed to
REDCapR::redcap_read_oneshot()
.