Skip to content

Part 6: Analysis and clean‐up phase

Felix Moerman edited this page May 2, 2024 · 7 revisions

Table of Contents

  • Congratulations, you have collected all the data you need for this project, and are soon ready to start analyzing your data.
  • In this part, we’ll discuss the different ways that you can clean, summarize, and export your data using the REDCap built-in functions.
  • From this point on, you can statistically analyze your data using a suite of statistical software (R, Python, Matlab, SAS, Stata, SPSS).
  • The ZHAW Services Forschungsdaten does however promote the use of script-based and ideally open-source methods to analyze data (e.g. R and Python).
  • To promote FAIR principles, the ZSF therefore also provides support to researchers who want to use or develop methods/tools with such script-based tools.
  • REDCap allows users to both 1) develop export formats for the data, 2) explore the data, and 3) export the data in several formats.
  • Lastly, REDCap also has a method to directly access data with external applications, using the API function.
  • We’ll walk through each of those methods in detail below, and demonstrate some examples using our movie survey example.
  • To start the process of exporting data, navigate to the “Data Exports, Reports, and Stats” page, by clicking the link on the left side of the page, under “Applications”:

6.1: Creating reports

  • To start our data exporting process, we can exactly define which data needs to be exported from REDCap.
  • This entails both defining what instruments and fields we are interested in, and what filtering criteria we want to include. Each REDCap project standard comes with two built-in reports: one report where all data is included, and one report where one can select individual instruments to be included in the report.
  • Additionally, REDCap provides the possibility to create one’s own reports, with a customized format and included instruments.
  • Creating such a report has multiple benefits:
    • It allows one to tailor the output for the planned analyses, for example only selecting the relevant instruments or fields that are needed for the planned analyses.
    • It allows a first quality control and filtering, for example by removing incomplete records from the data, before starting the analysis, or removing data where specific fields are empty (i.e. missing values for these topics)
    • It can provide another point for data anonymization, by only exporting fields that do no contain identifying information.
    • Finally, it allows to subset the data by selecting only fields containing specific values.
  • Let’s demonstrate this using our movie survey example:
    • Let’s start by clicking the “Create New Report” button, to start defining our report:

6.1.1: Main report settings

  • This will open a new window, in which we can specify all details of our report.
  • Let’s start by filling out the main information of our report.
  • With this report, we’ll get a report of our movie and review data, but let’s for now leave out the details of the individuals. Therefore, let’s name our report “movies report”.
  • We don’t want to make this public, so leave the checkbox empty.
  • And let’s also provide a brief summary of our report: “This report contains complete entries of movies and reviews, where the movie title is included.”:

6.1.2: Set report access rights

  • Next, in step one we want to define which users have access to this report.
  • We can, for example, specify specific users, user roles, or Data Access Groups (DAGs) that can access the report.
  • Additionally, we can assign similar rights to edit the report.
  • Because we only have a single user for the project, it does note make sense to change the settings, but especially in projects with many users or several DAGs, it may be important to assign correct view and edit rights.

6.1.3: Add fields to reports

  • Next, we want to specify which fields/instruments to export.

  • In our case, we want to select all fields from the movie information and movie evaluation forms.

  • Note that all forms will contain the record id (in our case participant ID) as a first record, as this is the obligatory ID field of the survey.

  • In principle, we can select each field from the two instruments, by selecting those from the drop-down list. But to import a whole instrument, there is a shortcut: on the upper right corner, the button “Choose instrument” next to “Add all fields from selected instrument” can be used to speed up the process:

  • Note that we have the possibility to customize some aspects, like adding “DAG” information, including timestamps/repeated instrument numbers (i.e. which instance of the repeated instrument is this instance), and removing line breaks:

  • Note that when one has repeating instruments or events, the standard REDCap report does not repeat data on each row.

  • For example, in our movie survey example, the information about participants is not repeated for every movie review they do, but listed in a separate row.

  • The data is however still connected, as all rows will contain the common record ID (here participant ID).

  • For easier data processing, it may therefore be more efficient to export the Participant information and movie information/evaluation data separately, and combine the two datasets later in your statistical software of choice.

6.1.4: Filtering report records

  • Next, we can filter our data, to remove incomplete entries or to select data with specific criteria.

  • For example, we can extract only movies with an overall rating of 85 or higher and where the movie information form is complete, by adding the following filtering conditions:

  • Finally, we can optionally order the records, for example by ascending participant_id.

  • Then, we can save our report, for future use:

6.2: Stats and summary

  • Now that we have made our report, we can actually look at some of the findings.

  • Although you’ll likely use the bulk of data visualization using an external statistical software, REDCap provides some convenient ways to glimpse at the data, and get some basic statistics and information.

  • At an early stage of the analysis process, this may be useful to get an idea on the number of records, the distribution of the data, and detect potential outliers.

  • For example, someone could have filled out their birthyear instead of their age in a survey or someone entered their size in cm, rather than meter.

  • Such kind of mistakes can be quickly detected, by looking at the distribution.

  • To do so, we can access the “stats and charts” section of reports.

  • Navigate to the “My reports and exports” tab, where this option is listed alongside “view report” and “Export data” for each report :

  • Click “Stats and charts” for the “All data” report, which should take you to a page where we can choose for which instrument we wish to see the information.

  • Select “Participant form”, to look at the statistics and graphs on the participants, in our survey.

  • As you can see, we’ve obtained a total of 7 records in our dataset (i.e. all individual records contained in our data). 3 of these records are “Participant forms”, and the 4 remaining ones are the events for the “Movie information form” and the “Movie review" forms.

  • REDCap provides some summary statistics for each of the fields in a survey (total number of entries, and the percentage missing).

  • For quantitative fields, it also provides some information on the distribution of the data.

  • For multiple choice questions, it additionally provides us with some plots showing the distribution of the records, among the possible choices.

  • Below, you can find the example output for the project.

  • Have a look at the output, or even better, play around with your own practice example on REDCap, to look at the data that you gathered yourself:

6.3: Exporting data

  • Now, as we have completed our data collection, checked our data, and prepared reports to bring our data outside of REDCap, we are finally ready to export our data, for statistical analysis.
  • REDCap has several built-in ways to export data for statistical analysis:
    • Export of project reports:
      • Export as CSV
      • Export to SPSS
      • Export to SAS
      • Export to R
      • Export to Stata
      • Export to cdisc ODM (XML)
    • Export all the project data:
      • As REDCap XML file
      • As zip file
      • As PDF file
  • We'll discuss the different methods here:

6.3.1: Exporting project reports

  • We can export project reports as CSV files, or for use in different statistical softwares (SPSS, SAS, R, Stata, ODM export).
  • In fact, all these export options are very similar, in the sense that REDCap does not export the data directly in a data file proprietary to that software.
  • Instead, REDCap produces a csv file containing the data from the selected instruments, and generates code for the relevant statistical software, to import the data into that software.
  • I will demonstrate this process here for our movie survey example, using the R statistical software (as this is the software I typically use for statistical analyses and I have installed on my computer. But the process should be equivalent for all other softwares).
  • First, navigate back to the “My Reports and Exports” tab. Here, we have an option “Export data”, that we will use for the “All data” report:

  • This will open a pop-up window, where we can select the relevant output.
  • I will choose “R statistical software”, but feel free to pick any other choice, if it better aligns with your typical analysis method.
  • Note that we also have some options such as whether to remove identifier fields, remove unvalidated text, or adjust the settings of the csv file (e.g. delimiter):

  • This will generate both the csv file, and the code to read the data into R. We can download both to the same folder to do our analysis:

  • If we then run this code, it will read in our data into R, and format it for use.
  • Note however, that because REDCap does not repeat data for our “Participant information form” in the data for the “Gather movie info” events, there are a lot of empty values in the data, and the information about the participants is displayed on different rows than the information on the movie reviews.

  • Therefore, in a case like our study, where some elements are repeating, it may be more efficient to export the data of the different events separately, and then concatenating the data in your software of choice.
  • For example, we can use the B) “selected instruments and or events” report, to separately export the data for the participants:

  • Then, repeat for the “Gather movie info” events:

  • We then can read both files into our statistical software (R for me), and then use a function to add the participant info to the movie info. In R, this would be the “right_join” function in the dplyr package:

  • Now, our dataset contains the four entries, one for each of the movie reviews, supplemented with all info on the participant:

6.3.2: Exporting the whole project

  • Finally, we can also export the whole project, either as a PDF file, as an XML file, or download a zip file of all uploaded objects:

  • These functions are not so useful for data analysis, but can have some uses in other cases:
    • Exporting XML files of the project may be useful, to either create a new project based on the current project and its data, or to share the project with another institute, that may run a different instance of REDCap.
    • Downloading the zip files of attachments that participants uploaded provides a convenient method to collect all this data, without accessing all these records individually. This may be pertinent if these attachments need to be further analyzed or processed.
    • Finally, downloading a PDF of the entire project allows to check all the answers to the surveys. This may be important when a person may need to check all answers (for example for completion of variables, missing data, etc), without that person having to go through every record individually, and without the risk that data is accidentally changed in the records.

6.4: API-functionality

  • Aside from these data export options using file export, REDCap has another way that data can be accessed through external applications: API (Application Program Interface) functionality.
  • API functionality allows external applications to access the data, using a unique API token.
  • This token can function as a password, allowing the external application access to either extract, add, or change data from the project. In REDCap, API functionality is primarily used for three goals:
    • Exporting data to Tableau for statistical analysis
    • Exporting data for external analysis/visualization using other software packages (e.g. R/Rshiny)
    • Use of the REDCap mobile app.
  • Whereas the first two applications primarily allow users to extract and analyze/visualize data, the first option also allows users to access projects, collect data, and add it to the project. A detailed instruction on the use of each of these three possibilities is beyond the scope of this training manual, but we’ll introduce users how to enable the use of API functionality, and how to request an API token for users.
  • In REDCap, API tokens are specific to both the user and the project. So a single API token can not be used for other REDCap projects. Whereas the API functionality is in principle possible to both export and import data from REDCap, not all API tokens can do both. This depends on whether the user for whom the API token has been requested has the correct user rights, that we first need to assign.

6.4.1: API rights management

  • In order to assign user rights for API functionality, first navigate to the “User Rights” page on the left of the screen, under the “Applications section:

  • From here, under the rights for the users, you’ll see an API option. This is disabled by default, even for the person who created the project:

  • To enable the rights, click on a person and then “Edit user rights”.
  • There you’ll notice that a user can be given API rights both for import and export. For our example, I’ll assign rights for both options to the user.
  • Then, we can save the changes to have them take effect.
  • After doing so, the user still needs to request an API token to be able to use this functionality:

6.4.2: Requesting API-tokens

  • API tokens can be requested by navigating to the “API” page, by clicking that link with the same name under the “Applications” section on the left side of the screen:

  • From here, we are taken to a page where we can request the API tokens for the users. Click the “Create new API token” button:

  • This will generate a request for an API token, that needs to be validated at ZHAW Services Forschungsdaten, before you can use it.
  • After it has been validated, you will see a screen where you can copy your API token from, and use it to access the project with external applications:

  • IMPORTANT: Treat this token with confidentiality and care! With it, others may be able to access your project. Thus never share this token and don’t use it in publicly available code!