View source: R/exportFilesMultiple.R
exportFilesMultiple | R Documentation |
This method enables the user to export multiple files from
a REDCap project with a single call. The REDCap API only allows for one
file to be exported per call, and the exportFiles()
methods are written
to mirror that limitation. This extension allows the user to pass
vectors of arguments for records, fields, events, or repeat instances.
Files that can be matched to any combination of these values will
be exported.
exportFilesMultiple(
rcon,
record,
field,
event = NULL,
dir,
file_prefix = TRUE,
...
)
## S3 method for class 'redcapApiConnection'
exportFilesMultiple(
rcon,
record,
field,
event = NULL,
dir,
file_prefix = TRUE,
repeat_instance = NULL,
...,
quiet = TRUE
)
rcon |
A |
record |
|
field |
|
event |
|
dir |
|
file_prefix |
|
... |
Arguments to pass to other methods |
repeat_instance |
|
quiet |
|
exportFilesMultiple
will construct all combinations of
the record
, field
, event
, and repeat_instance
arguments and
attempt to export the file associated with each combination. Should any
of these combinations produce an error (for example, if a record does not
have a third repeat instance), the error is captured and returned
with the output.
Invisibly returns a data.frame
with the following columns:
Column | Description |
record | The record ID |
field | The name of the field in which the file is stored. |
event | The name of the event associated with the file. |
repeat_instance | For repeat instances, the instance associated with the file. |
is_exported | logical indicating if the file was successfully exported. |
saved_to | The file path to which the file was saved. |
error | If an error was encountered, the text of the error. |
exportFiles()
## Not run:
unlockREDCap(connections = c(rcon = "project_alias"),
url = "your_redcap_url",
keyring = "API_KEYs",
envir = globalenv())
save_to_dir <- tempdir()
# Export files for multiple records
# Results are returned invisibly - saving to an object is
# helpful to be able to view the results
Export <-
exportFilesMultiple(rcon,
record = 1:4,
field = "file_upload_field",
event = "event_1_arm_1",
dir = save_to_dir)
Export
# Export files for multiple instances
Export <-
exportFilesMultiple(rcon,
record = 1,
field = "file_upload_field",
event = "event_1_arm_1",
repeat_instance = 1:4,
dir = save_to_dir)
Export
# Export files for multiple records, fields, events, and instances
Export <-
exportFilesMultiple(rcon,
record = 1:10,
field = c("registration", "waiver"),
events = c("event_1_arm_1", "event_2_arm_1"),
repeat_instance = 1:3,
dir = save_to_dir)
Export
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.