| exportBulkRecords {redcapAPI} | R Documentation |
A helper function to export multiple records and forms using a single call.
Description
Exports records from multiple REDCap Databases using
multiple calls to exportRecordsTyped()
Usage
exportBulkRecords(
lcon,
forms = NULL,
envir = NULL,
sep = "_",
post = NULL,
...
)
Arguments
lcon |
A named list of connections. The name is used as a prefix for data.frame names in the environment specified. It may also be used as a reference from the forms argument. |
forms |
A named list that is a subset of rcon's names. A specified |
envir |
A environment to write the resulting Records in as variables
given by their name in rcon or if from a form their rcon named pasted to
their form name joined by |
sep |
A character string to use when joining the rcon name to the form name for storing variables. |
post |
A function that will run on all returned sets of Records. |
... |
Any additional variables to pass to |
Value
Will return a named list of the resulting records if envir is
NULL. Otherwise will assign them to the specified envir.
See Also
Other records exporting functions
exportRecordsTyped(),
exportRecords(),
exportReports()
Field validations and casting
fieldValidationAndCasting(),
reviewInvalidRecords()
Post-processing functionality
recastRecords(),
guessCast(),
guessDate(),
castForImport(),
mChoiceCast(),
splitForms(),
widerRepeated()
Vignettes
vignette("redcapAPI-offline-connection")
vignette("redcapAPI-casting-data")
vignette("redcapAPI-missing-data-detection")
vignette("redcapAPI-data-validation)
vignette("redcapAPI-faq)
Examples
## Not run:
unlockREDCap(c(test_conn = 'TestRedcapAPI',
sandbox_conn = 'SandboxAPI'),
keyring = 'MyKeyring',
envir = globalenv(),
url = 'https://<REDCAP_URL>/api/')
# After user interaction to unlock the local encrypted keyring
# the global environment will contain the REDCap connections
# `test_conn` and `sandbox_conn`
#
# Next the user wants to bulk specify importing all the forms
# of interest and post process
exportBulkRecords(
rcon = list(test = test_conn,
sand = sandbox_conn),
forms = list(test = c('form1', 'form2'),
envir = globalenv(),
post = function(Records, rcon)
{
Records |>
mChoiceCast(rcon) |>
guessDat(rcon) |>
widerRepeating(rcon)
}
)
# The environment now contains the data.frames: `test.form1`, `test.form2`, `sand`.
# Each of these were retrieved, possibly using the forms argument and all were
# post processed in the same manner as specified by `post`.
## End(Not run)