rc_bundle: Export REDCap project metadata

View source: R/rc_bundle.R

rc_bundleR Documentation

Export REDCap project metadata

Description

This function performs several API calls at once in order to reduce the overall number of calls when using rctools. All project metadata is exported and saved to a REDCap bundle option and/or object for use with other rctools functions.

Usage

rc_bundle(
  url,
  token,
  create_options = TRUE,
  return_object = TRUE,
  data_dict = FALSE,
  users = FALSE,
  instruments = FALSE,
  event_data = FALSE,
  arms = FALSE,
  mappings = FALSE,
  proj_info = FALSE,
  version = FALSE
)

Arguments

url

A url address to connect to the REDCap API

token

Path to a text file containing your REDCap API token

create_options

Logical. Indicates whether the REDCap bundle, token, and url should be uploaded to the R session options.

return_object

Logical. Indicates whether the REDCap bundle should be returned as an object.

data_dict

Logical. Indicates if the meta data (data data_dictionary) should be exported.

users

Logical. Indicates if the users table should be exported.

instruments

Logical. Indicates if the instruments table should be exported.

event_data

Logical. Indicates if the event names should be exported.

arms

Logical. Indicates if the arms table should be exported.

mappings

Logical. Indicates if the form-event mappings should be exported.

proj_info

Logical. Indicates if the project information should be exported. If the project is not longitudinal, the events, arms, and event-form mappings elements will be assigned character vectors instead of data frames.

version

Logical. Indicates if the REDCap version number should be exported. Only applicable in REDCap 6.0.0 and higher.

Details

By default, this function exports all metadata. If any of the metadata arguments are set to TRUE, then only the indicated data will be exported. Additionally, by default the exported data will be saved to the option "redcap_bundle", and other rctools functions will check this option for metadata by default. The bundle can be accessed via getOption("redcap_bundle"). It will also be returned as an object (by default) for ease of access. Saving the bundle object as an RDS (see saveRDS()) or within your workspace image (see save.image()) is useful to negate the need for additional API calls in future sessions.

For security purposes, the REDCap token will be saved only to the option "redcap_token". This option, along with the "redcap_bundle" option, will not persist across R sessions. Unlike the REDCap bundle data, saving a token within an object or workspace is not recommended.

Author(s)

Marcus Lehr

Benjamin Nutter


chillywings/rctools documentation built on Aug. 9, 2024, 11:52 p.m.