Skip to contents

This function allows users to read datasets from a REDCap project into R for analysis, either by exporting the data or via an API connection.

The REDCap API serves as an interface for communication with REDCap and the server without requiring interaction through the REDCap interface.

[Important] To read exported data from REDCap, please follow these steps:

- Use REDCap's 'Export Data' function.

- Select the 'R Statistical Software' format.

- REDCap will then generate two files:

- A CSV file containing all observations of the REDCap project.

- An R file with the necessary code to complete each variable's information and import them.

- Ensure these files, along with the dictionary and event-mapping, are in the same directory.


  data_path = NA,
  dic_path = NA,
  event_path = NA,
  uri = NA,
  token = NA,
  filter_field = NA



Character string specifying the path of the R file from which the dataset will be read.


Character string with the path of the dictionary.


Character string specifying the path of the file containing the correspondence between each event and each form (downloadable via the `Designate Instruments for My Events` tab within the `Project Setup` section of REDCap).


The URI (Uniform Resource Identification) of the REDCap project.


Character vector containing the generated token.


Character vector specifying the fields of the REDCap project desired to be imported into R (via API connection only).


A list containing the dataset and the dictionary of the REDCap project. If `event_path` is specified, it will also contain a third element with the correspondence of the events and forms of the project.


For further use of the package, it's recommended to use the `dic_path` argument to read the dictionary, as all other functions require it for proper functioning.


if (FALSE) {
# Exported files from REDCap

dataset <- redcap_data(data_path = "C:/Users/username/example.r",
                       dic_path = "C:/Users/username/example_dictionary.csv",
                       event_path = "C:/Users/username/events.csv")

# API connection

dataset_api <- redcap_data(uri = "",
                           token = "55E5C3D1E83213ADA2182A4BFDEA") # This token is fictitious