# NOT RUN {
library(REDCapR) #Load the package into the current R session.
uri <- "https://bbmc.ouhsc.edu/redcap/api/"
token <- "D70F9ACD1EDD6F151C6EA78683944E98"
# }
# NOT RUN {
project <- 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_three_columns <- project$read(fields=c("record_id", "sex", "height"))$data
ids_of_males vv <- ds_three_columns$record_id[ds_three_columns$sex==1]
ids_of_shorties <- ds_three_columns$record_id[ds_three_columns$height < 40]
ds_males <- project$read(records=ids_of_males, batch_size=2)$data
ds_shorties <- project$read(records=ids_of_shorties)$data
#Switch the Genders
sex_original <- ds_three_columns$sex
ds_three_columns$sex <- (1 - ds_three_columns$sex)
project$write(ds_three_columns)
#Switch the Genders back
ds_three_columns$sex <- sex_original
project$write(ds_three_columns)
# }
Run the code above in your browser using DataLab