REDCapTidieR 1.2.0 🎉

Open Source
REDCap
REDCapTidieR
R
REDCapTidieR v1.2.0 Release
Author

Stephan Kadauke, Ezra Porter, Richard Hanna

Published

October 24, 2024

We’re thrilled to announce the release of REDCapTidieR v1.2.0 on CRAN. Since our 1.0.0 release, we’ve updated the core packagage with new features and improvements designed to make your data extraction and tidying processes smoother and more efficient than ever. Let’s dive into what’s new!

You can install the package from CRAN with:

install.packages("REDCapTidieR")

🛠️ New Features to Support Supertibble Post-Processing

âś… Introducing combine_checkboxes(): Simplify Your Checkbox Data

Checkbox fields (also known as multi-select) in REDCap are notoriously challenging to work with since they become a separate field for each selection option in the extracted output. Most of the time this is useful and REDCapTidieR automatically handles checkbox fields for you. Let’s refresh and look at a simple example below with a standard output. We’ll use a pared-down version of a supertibble containing a single non-repeating instrument with REDCap data and metadata related to study participant race:

library(REDCapTidieR)

supertbl

Now let’s inspect the data tibble for the demographic_instrument:

supertbl |> 
  extract_tibble("demographic_instrument")

Notice how REDCapTidieR automatically handles the original multi/checkbox variable, race, and splits it into six new fields representing the selection options starting with race___1 and ending with race___6.

Sometimes this is enough, but in this example it may be better to consolidate these fields under a single variable. In the example above, a desired output could be:

tibble::tribble(
  ~"study_id", ~"race",
  1, "American Indian/Alaska Native",
  2, "Multiple",
  3, "None"
)

In this scenario, single selection options persist in the consolidated column, but multiple selections get assigned a new label. Let’s use combine_checkboxes() to handle this:

combine_checkboxes(
    supertbl = supertbl,
    tbl = "demographic_instrument",
    cols = starts_with("race"),
    multi_value_label = "Multiple",
    values_fill = "None"
) |> 
  extract_tibble("demographic_instrument")

The new variable we modeled above appears at the end of the data tibble! If you are used to the tidyr package, you may notice that some inspiration is taken here from the syntax for pivoting functions. It’s important to note that combine_checkboxes() both accepts and returns a supertibble object, so to view your changes you will need to specifically inspect the data tibble in question.

Mixed Structure Instrument Support

In the release of REDCapTidieR v1.1.0, we introduced support for what we call “mixed structure” instruments. These occur when the same instrument is designated as both a repeating and nonrepeating instrument. By default mixed structure instruments will result in a read_redcap() error because of how it clashes with the “tidy” principles the package is built on.

However, sometimes mixed structure instruments are unavoidable. By setting allow_mixed_structure = TRUE in read_redcap(), users can now include mixed structure data tibbles in their supertibble outputs. Nonrepeating variants of mixed structure instruments will be treated as repeating instruments with a single repeating instance.

For more information, check out the Mixed Structure Instruments section of the Diving Deeper vignette.

📚 New Vignette: “Using Labelled Vectors with REDCapTidieR”

REDCapTidieR has supported labelled data for a while, and offers several functions to help users apply labels. We’ve expanded on this documentation by adding a comprehensive new vignette titled “Using Labelled Vectors with REDCapTidieR” written to guide you through leveraging labelled vectors to maintain meaningful metadata in your datasets, enhancing both readability and usability.

🔎 New Supertibble Column Information

The supertibble output now includes a new metadata column, form_complete_pct, which shows the percentage of a given instrument that has a form status marked as “Complete” (green), giving you a quick overview of your data completeness.

event_name has now been added to the columns under the redcap_events metadata column, displaying the event label for each REDCap event in longitudinal projects.

For projects with repeating events, a new repeat_type column has been added to display whether the associated instrument under redcap_events is a “repeat_together”, “repeat_separate”, or “nonrepeating” event.

đź‘‹ Until the Next Update

Thank you for being a part of the REDCapTidieR user base! Your feedback is always appreciated and drives us to keep making a better package! 🎉