uri <- "https://bbmc.ouhsc.edu/redcap/api/"
token <- "9A81268476645C4E5F03428B8AC3AA7B"
if (FALSE) {
project <- REDCapR::redcap_project$new(redcap_uri=uri, token=token)
ds_all <- project$read()
# Demonstrate how repeated calls are more concise when the token and
# url aren't always passed.
ds_skinny <- project$read(fields=c("record_id", "sex", "height"))$data
ids_of_males <- ds_skinny$record_id[ds_skinny$sex==1]
ids_of_shorties <- ds_skinny$record_id[ds_skinny$height < 40]
ds_males <- project$read(records=ids_of_males, batch_size=2)$data
ds_shorties <- project$read(records=ids_of_shorties)$data
}
if (FALSE) {
# Switch the Genders
sex_original <- ds_skinny$sex
ds_skinny$sex <- (1 - ds_skinny$sex)
project$write(ds_skinny)
# Switch the Genders back
ds_skinny$sex <- sex_original
project$write(ds_skinny)
}
Run the code above in your browser using DataLab