Skip to content

CRAN 1.2.2 Prep #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: Extract 'REDCap' Databases into Tidy 'Tibble's
Version: 1.2.2
Authors@R: c(
person("Richard", "Hanna", , "richardshanna91@gmail.com", role = c("aut", "cre"),
person("Richard", "Hanna", , "hannar1@chop.edu", role = c("aut", "cre"),
comment = c(ORCID = "0009-0005-6496-8154")),
person("Stephan", "Kadauke", , "kadaukes@chop.edu", role = "aut",
comment = c(ORCID = "0000-0003-2996-8034")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# REDCapTidieR 1.2.2

- Fixed a bug where, when using `raw_or_label = "label"` and requesting DAGs, only raw values for DAGs would be retrieved
- Adds variable labels for `form_complete_pct`, `event_name`, and `repeat_type` when `make_labelled()` is called

# REDCapTidieR 1.2.1

Expand Down
9 changes: 5 additions & 4 deletions R/combine_checkboxes.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#' @return A modified supertibble.
#'
#' @examples
#' library(dplyr)
#' # Set up sample data tibble
#' data_tbl <- tibble::tribble(
#' ~"study_id", ~"multi___1", ~"multi___2", ~"multi___3",
Expand Down Expand Up @@ -69,8 +70,8 @@
#' supertbl = supertbl,
#' tbl = "tbl",
#' cols = starts_with("multi")
#' ) |>
#' dplyr::pull(redcap_data) |>
#' ) %>%
#' dplyr::pull(redcap_data) %>%
#' dplyr::first()
#'
#' \dontrun{
Expand Down Expand Up @@ -250,7 +251,7 @@ replace_true <- function(col, col_name, metadata, raw_or_label) {
pull(raw_or_label)
col <- ifelse(col == TRUE, replacement, NA) # col == TRUE works for raw or label because TRUE == 1 & 1 == TRUE
# Convert non-TRUEs to NA, since values can be either "FALSE" or "0" for unchecked values
return(col)
col
}

#' @title Convert a new checkbox column's values
Expand Down Expand Up @@ -328,5 +329,5 @@ combine_and_repair_tbls <- function(data_tbl, data_tbl_mod, new_cols, names_repa
# Combine the selected columns
combined_data <- bind_cols(common_data, unique_data_mod)

return(combined_data)
combined_data
}
2 changes: 1 addition & 1 deletion R/read_redcap.R
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ get_repeat_event_types <- function(data) {
#' @title Implement REDCapR DAG Data into Supertibble
#'
#' @description
#' This helper function uses output from [redcap_dag_read] and applies the necessary
#' This helper function uses output from [REDCapR::redcap_dag_read] and applies the necessary
#' raw/label values to the `redcap_data_access_group` column.
#'
#' This is done because REDCapTidieR retrieves raw data by default, then merges
Expand Down
24 changes: 12 additions & 12 deletions R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description
#' Transform a supertibble into an XLSX file, with each REDCap data tibble in a separate sheet.
#'
#' @param supertbl A supertibble generated using `read_redcap()`.
#' @param supertbl A supertibble generated using [read_redcap()].
#' @param file The name of the file to which the output will be written.
#' @param add_labelled_column_headers If `TRUE`, the first row of each sheet will contain variable labels,
#' with variable names in the second row. If `FALSE`, variable names will be in the first row.
Expand Down Expand Up @@ -207,8 +207,8 @@ write_redcap_xlsx <- function(supertbl,
#' @description
#' Helper function to support `labelled` aesthetics to XLSX supertibble output
#'
#' @param supertbl a supertibble generated using `read_redcap()`
#' @param supertbl_meta supertibble metadata generated by `bind_supertbl_metadata()`
#' @param supertbl a supertibble generated using [read_redcap()]
#' @param supertbl_meta supertibble metadata generated by [bind_supertbl_metadata()]
#' @param wb An `openxlsx2` workbook object
#' @param sheet_vals Helper argument passed from `write_redcap_xlsx` to
#' determine and assign sheet values.
Expand All @@ -230,7 +230,7 @@ add_labelled_xlsx_features <- function(supertbl,
supertbl_toc = NULL) {
check_installed("labelled", reason = "to make use of labelled features in `write_redcap_xlsx`")
# Generate variable labels off of labelled dictionary objects ----
generate_dictionaries <- function(x) {
generate_dictionaries <- function(x) { #nolint: object_usage_linter
labelled::generate_dictionary(x) %>%
select("variable", "label") %>%
mutate(label = if_else(is.na(.data$label), "", .data$label)) %>%
Expand Down Expand Up @@ -284,7 +284,7 @@ add_labelled_xlsx_features <- function(supertbl,
}

# Define redcap_data variable labels
var_labels <- supertbl$redcap_data %>% map(\(x) generate_dictionaries(x))
var_labels <- map(.x = supertbl$redcap_data, ~generate_dictionaries(.x))

for (i in seq_along(supertbl$redcap_form_name)) {
wb$add_data(
Expand Down Expand Up @@ -316,13 +316,13 @@ add_labelled_xlsx_features <- function(supertbl,
#' Internal helper function. Adds appropriate elements to `wb` object. Returns
#' a dataframe.
#'
#' @param supertbl a supertibble generated using `read_redcap()`
#' @param supertbl a supertibble generated using [read_redcap()]
#' @param wb An `openxlsx2` workbook object
#' @param include_metadata_sheet Include a sheet capturing the combined output of the
#' supertibble `redcap_metadata`.
#' @param add_labelled_column_headers Whether or not to include labelled outputs.
#' @param table_style Any excel table style name or "none" (see "formatting"
#' vignette in \link[openxlsx2]{wb_add_data_table}). Default "tableStyleLight8".
#' in [openxlsx2::wb_add_data_table()]). Default "tableStyleLight8".
#' @param column_width Width to set columns across the workbook. Default
#' "auto", otherwise a numeric value. Standard Excel is 8.43.
#' @param na_replace The value used to replace `NA` values in `supertbl`. The default is "".
Expand Down Expand Up @@ -400,12 +400,12 @@ add_supertbl_toc <- function(wb,
#' Internal helper function. Adds appropriate elements to `wb` object. Returns
#' a dataframe.
#'
#' @param supertbl a supertibble generated using `read_redcap()`
#' @param supertbl a supertibble generated using [read_redcap()]
#' @param supertbl_meta an `unnest`-ed metadata tibble from the supertibble
#' @param wb An `openxlsx2` workbook object
#' @param add_labelled_column_headers Whether or not to include labelled outputs.
#' @param table_style Any excel table style name or "none" (see "formatting"
#' vignette in \link[openxlsx2]{wb_add_data_table}). Default "tableStyleLight8".
#' in [openxlsx2::wb_add_data_table()]). Default "tableStyleLight8".
#' @param column_width Width to set columns across the workbook. Default
#' "auto", otherwise a numeric value. Standard Excel is 8.43.
#' @param na_replace The value used to replace `NA` values in `supertbl`. The default is "".
Expand Down Expand Up @@ -442,7 +442,7 @@ add_metadata_sheet <- function(supertbl,
#' Checks if a supplied supertibble is labelled and throws an error if it is not
#' but `labelled` is set to `TRUE`
#'
#' @param supertbl a supertibble generated using `read_redcap()`
#' @param supertbl a supertibble generated using [read_redcap()]
#' @param add_labelled_column_headers Whether or not to include labelled outputs
#' @param call the calling environment to use in the warning message
#'
Expand Down Expand Up @@ -500,7 +500,7 @@ check_labelled <- function(supertbl, add_labelled_column_headers, call = caller_
#' This utility function helps to map metadata field types in order to apply
#' changes in supertbl tables.
#'
#' @param supertbl A supertibble generated using `read_redcap()`
#' @param supertbl A supertibble generated using [read_redcap()]
#' @param supertbl_meta an `unnest`-ed metadata tibble from the supertibble
#' @param add_labelled_column_headers Whether or not to include labelled outputs
#'
Expand Down Expand Up @@ -555,7 +555,7 @@ supertbl_recode <- function(supertbl, supertbl_meta, add_labelled_column_headers
#' Simple helper function for binding supertbl metadata into one table. This
#' supports creating the metadata XLSX sheet as well as `supertbl_recode`.
#'
#' @param supertbl A supertibble generated using `read_redcap()`
#' @param supertbl A supertibble generated using [read_redcap()]
#'
#' @keywords internal

Expand Down
6 changes: 1 addition & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

Thank you for taking the time to review this submission and please reach out to either Stephan Kadauke, Richard Hanna, or Ezra Porter for any questions, comments, or concerns.

This submission for v1.2.1 patches one bug and adds one new feature update.

## New Features

The only new feature in this release allows for factor levels to be passed in part of the package output.
This submission for v1.2.2 patches two minor bugs related to data access group handling and labels.

## Test environments

Expand Down
2 changes: 1 addition & 1 deletion man/REDCapTidieR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/add_labelled_xlsx_features.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/add_metadata_sheet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/add_supertbl_toc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bind_supertbl_metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/check_labelled.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/combine_checkboxes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/supertbl_recode.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/update_dag_cols.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/write_redcap_xlsx.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.