Exporting to ExcelSource:
Excel spreadsheets are an accessible medium for data analysis and collaboration. This vignette will guide you through the process of using REDCapTidieR to transform your REDCap data into an XLSX document, facilitating easy sharing with colleagues.
Below is a practical illustration:
redcap_uri <- "https://my.institution.edu/redcap/api/" token <- "123456789ABCDEF123456789ABCDEF04" my_redcap_data <- read_redcap(redcap_uri, token) write_redcap_xlsx(my_redcap_data, file = "my_redcap_data.xlsx")
The resulting file will contain the data corresponding to each REDCap instrument in a dedicated sheet. Additionally, a “Table of Contents” sheet will be at the beginning, and a “REDCap Metadata” sheet will be at the end.
We will revisit the Superheroes dataset from the Getting Started vignette.
superheroes_token <- "123456789ABCDEF123456789ABCDEF04" redcap_uri <- "https://my.institution.edu/redcap/api/"
superheroes supertibble contains two rows, one for
each instrument of the
Superheroes REDCap project. The
write_redcap_xlsx() function, leveraging the openxlsx2 package,
understands the supertibble’s structure and creates a
collaborator-friendly XLSX file.
Let’s try it out!
superheroes |> write_redcap_xlsx(file = "superheroes.xlsx")
When you open the Excel document, you’ll see multiple sheets. The first one is the Table of Contents sheet, followed by individual sheets for each instrument’s data, and concluded with a REDCap Metadata sheet.
The Table of Contents sheet provides an overview of
the data present in the rest of the document. If you wish to exclude
this sheet, set the
include_toc_sheet argument of
Each instrument’s data is contained in a separate sheet. For a better understanding of how REDCapTidieR represents REDCap data, refer to the Diving Deeper vignette.
The column headers come with pre-applied filters (notice the arrow on the right side of each header cell), making data exploration straightforward.
The REDCap Metadata sheet offers metadata for
all fields from all instruments in one place. If you
don’t want this sheet, set the
Labels can offer valuable context to collaborators, helping them
understand the data in a specific column. The
make_labelled() function allows you to add variable labels to a
REDCapTidieR supertibble, and
write_redcap_xlsx() can integrate these labels to the Excel
Let’s add variable labels to
superheroes and export it
Observe how the first row now contains a human-readable description for each column.
write_redcap_xlsx() recodes logical
FALSE) columns into more human-friendly
terms. You can adjust this behavior using the
supertbl |> write_redcap_xlsx(recode_logical = TRUE)
- Columns derived from yesno fields are recoded from
- Columns derived from checkbox fields are recoded
- Columns derived from truefalse fields are left as
preserve all logical fields as