Skip to content

Commit

Permalink
use magrittr pipes for a little longer
Browse files Browse the repository at this point in the history
ref #500
  • Loading branch information
wibeasley committed Jul 15, 2023
1 parent 5f89356 commit 61dc0f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/metadata-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#' choices_3 <- ds_metadata_3[ds_metadata_3$field_name=="race", "select_choices_or_calculations"]
#' REDCapR::regex_named_captures(pattern = pattern_boxes, text = choices_3)

#' @importFrom magrittr %>%
#' @export
regex_named_captures <- function(pattern, text, perl = TRUE) {
checkmate::assert_character(pattern, any.missing = FALSE, len = 1, min.chars = 0L)
Expand Down Expand Up @@ -114,8 +115,10 @@ regex_named_captures <- function(pattern, text, perl = TRUE) {
checkbox_choices <- function(select_choices) {
checkmate::assert_character(select_choices, any.missing=FALSE, len=1, min.chars=1)

strsplit(select_choices, split = "|", fixed = TRUE)[[1]] |>
I() |>
select_choices %>%
strsplit(split = "|", fixed = TRUE) %>%
magrittr::extract2(1) %>%
I() %>%
readr::read_csv(
col_names = c("id", "label"),
col_types = "cc"
Expand Down

0 comments on commit 61dc0f8

Please sign in to comment.