Querying REDCap database fails in targets pipeline #625
-
I have data in a REDCap database that I want to pull into R via the REDCap API using the
(with values for I want to do this within a targets plan like the following
However, running
Do you have any idea why I'm able to access the url outside of a targets plan but not inside of one? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
tar_target(
name = data,
command = redcap_read(token = Sys.getenv("YOUR_TOKEN")),
format = "feather" # assuming data frame format
cue = tarchetypes::tar_cue_force(redcap_changed(Sys.getenv("YOUR_TOKEN")))
) where |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late reply. This solved the issue, thanks! |
Beta Was this translation helpful? Give feedback.
format = "url"
is for when you have a specific file in mind at a URL, e.g. https://raw.githubusercontent.com/wlandau/targets-minimal/main/data/raw_data.csv. For APIs, I would recommend something like:where
redcap_changed()
is a function you write to check if the remote database changed (using the last modified time stamp or hash of the database table).tarchetypes
has a bunch of alternatives for this sort of thing, such astar_change()
,tar_age()
, andtar_cue_age()
.