Skip to content

Commit

Permalink
Merge pull request #188 from CHOP-CGTInformatics/form_complete_pct
Browse files Browse the repository at this point in the history
Form Complete Metadata Column for Supertibble
  • Loading branch information
rsh52 authored Mar 25, 2024
2 parents 85244b4 + 5001995 commit 28339bb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# REDCapTidieR (development version)

# REDCapTidieR 1.1.0

- `read_redcap()` now supports instruments that follow a mixed repeating/non-repeating structure with the `allow_mixed_structure` parameter
- When enabled, instruments with mixed repeating/nonrepeating structure will be treated as single-instance repeating instruments
- A new metadata column, `form_complete_pct`, is now available when viewing the supertibble showing the percentage of a given instrument that has a form status marked as "Complete" (green)

# REDCapTidieR 1.0.0

Expand Down
8 changes: 6 additions & 2 deletions R/read_redcap.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ add_metadata <- function(supertbl, db_metadata, redcap_uri, token, suppress_redc
unnest_wider(summary) %>%
relocate(
"redcap_form_name", "redcap_form_label", "redcap_data", "redcap_metadata",
"structure", "data_rows", "data_cols", "data_size", "data_na_pct"
"structure", "data_rows", "data_cols", "data_size", "data_na_pct", "form_complete_pct"
)
}

Expand Down Expand Up @@ -488,9 +488,13 @@ calc_metadata_stats <- function(data) {
is.na() %>%
mean()

form_complete_pct <- data %>%
summarise(avg_complete = mean(.data$form_status_complete == 2))

list(
data_rows = nrow(data), data_cols = ncol(data),
data_size = obj_size(data),
data_na_pct = percent(na_pct, digits = 2, format = "fg")
data_na_pct = percent(na_pct, digits = 2, format = "fg"),
form_complete_pct = percent(form_complete_pct, digits = 2, format = "fg")
)
}
2 changes: 1 addition & 1 deletion R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ add_supertbl_toc <- function(wb,
select(-any_of(c("redcap_data", "redcap_metadata", "redcap_events"))) %>%
# Necessary to avoid "Number stored as text" Excel dialogue warnings
mutate(
across(any_of("data_na_pct"), convert_percent),
across(any_of(c("data_na_pct", "form_complete_pct")), convert_percent),
across(any_of("data_size"), ~ prettyunits::pretty_bytes(as.numeric(.)))
)

Expand Down
Binary file modified man/figures/write_xlsx_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 28339bb

Please sign in to comment.