download_redcap_records() downloads records from a REDcap project
download_redcap_records(
api_token,
dir,
file,
headers = c("raw", "label"),
values = c("label", "raw"),
filter = NULL,
fields = NULL,
force = FALSE
)
Arguments
| api_token |
character. API token/key for accessing the project
programmatically. Best practice is to set as an environment variable and
retrieve using Sys.getenv("token_environment_variable"). See
env-variables for more information.
|
| dir |
character. Directory to save data; this should usually remain
unchanged.
|
| file |
character. File name for data; this should usually remain
unchanged. The resulting file will always have a "csv" extension; if
you pass a file name without a "csv" extension, the function will
replace it with a warning.
|
| headers |
"raw" or "label". Should column names ("headers") be
exported as the raw variable names ("raw", the default) or the label
shown in the UI ("label")?
|
| values |
"raw" or "label". Should values in multiple-choice and
checkbox fields be exported as the raw coded value ("raw", the default)
or the label for the coded value ("label")?
|
| filter |
character. REDcap filtering logic to apply prior to download.
This must be in the REDcap logic syntax.
|
| fields |
character. A vector of field names to include; if NULL,
all fields will be downloaded.
|
| force |
Should the download overwrite an existing file, if one exists?
The default is FALSE, which errors if an existing file is found. |
Value
The path to the data as an fs_path character vector