OuhscBbmc / REDCapR

R utilities for interacting with REDCap
https://ouhscbbmc.github.io/REDCapR
Other
112 stars 45 forks source link

redcap_download_file_oneshot() only downloads from instance 1 regardless of repeat_instance value #506

Open nathhenry3 opened 11 months ago

nathhenry3 commented 11 months ago

I am trying to use the redcap_download_file_oneshot() function to extract files for specific variables from a large REDCap project. This project has repeating instruments, and so I am running the function in a loop for multiple values of 'instance' to download all files for each repeated instance.

However, it appears that the function is only downloading the file from the first instance of the repeating instrument, regardless of the value of repeat_instance.

Here's the code that I'm running:

file_download <- REDCapR::redcap_download_file_oneshot(redcap_uri = uri, token = api_token, record = record_id, field = field_name, event = event_name, repeat_instance = instance, directory = directory, overwrite = TRUE, verbose = TRUE )

where 'instance' changes with each iteration.

Desktop:

Thanks a lot!

BlairCooper commented 11 months ago

Looks like you need to also provide the repeat_instrument parameter.

nathhenry3 commented 11 months ago

Ahh that's working now, thank you. However this was not immediately obvious on first sight.

Is it possible to include some sort of error message if repeat_instance is modified, but repeat_instrument is not included? Currently the download silently reverts to the first instance, which is easy to miss.