Learn R Programming

REDCapR (version 0.9.3)

redcap_project: A Reference Class to make later calls to REDCap more convenient.

Description

This Reference Class represents a REDCap project. Once some values are set that are specific to a REDCap project (such as the URI and token), later calls are less verbose (such as reading and writing data). The functionality

Arguments

Fields

redcap_uri
The URI (uniform resource identifier) of the REDCap project. Required.
token
token The user-specific string that serves as the password for a project. Required.

Methods

read(batch_size = 100L, interbatch_delay = 0, records = NULL, records_collapsed = "", fields = NULL, fields_collapsed = "", export_data_access_groups = FALSE, raw_or_label = "raw", verbose = TRUE, config_options = NULL)
Exports records from a REDCap project.
write(ds_to_write, batch_size = 100L, interbatch_delay = 0, verbose = TRUE, config_options = NULL)
Imports records to a REDCap project.

Examples

Run this code
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)
# dsAll <- project$read()
# 
# #Demonstrate how repeated calls are more concise when the token and url aren't always passed.
# dsThreeColumns <- project$read(fields=c("record_id", "sex", "height"))$data
# 
# idsOfMales <- dsThreeColumns[dsThreeColumns$sex==1, "record_id"]
# idsOfShorties <- dsThreeColumns[dsThreeColumns$height < 40, "record_id"]
# 
# dsMales <- project$read(records=idsOfMales, batch_size=2)$data
# dsShorties <- project$read(records=idsOfShorties)$data
# 
# #Switch the Genders
# sex_original <- dsThreeColumns$sex
# dsThreeColumns$sex <- (1 - dsThreeColumns$sex)
# project$write(dsThreeColumns)
# 
# #Switch the Genders back
# dsThreeColumns$sex <- sex_original
# project$write(dsThreeColumns)
# ## End(Not run)

Run the code above in your browser using DataLab