From abb9100dafa78fa1474f15403656641625f5905f Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 13 Jul 2023 15:34:41 -0500 Subject: [PATCH] replace native pipes for now --- R/validate.R | 12 ++++++------ tests/testthat/test-arm-export.R | 2 +- tests/testthat/test-event-read.R | 2 +- tests/testthat/test-project-info-read.R | 6 +++--- tests/testthat/test-validate-no-logical.R | 14 +++++++------- tests/testthat/test-validate-repeat.R | 2 +- tests/testthat/test-validate.R | 14 +++++++------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/R/validate.R b/R/validate.R index 18c4341d..5518a600 100644 --- a/R/validate.R +++ b/R/validate.R @@ -272,8 +272,8 @@ validate_record_id_name <- function( suggestion = character(0) ) } else if (stop_on_error) { - "The field called `%s` is not found in the dataset.\nAdjust the value passed to the `record_id_name` if this isn't the correct named used by your specific REDCap project." |> - sprintf(record_id_name) |> + "The field called `%s` is not found in the dataset.\nAdjust the value passed to the `record_id_name` if this isn't the correct named used by your specific REDCap project." %>% + sprintf(record_id_name) %>% stop() } else { tibble::tibble( @@ -335,11 +335,11 @@ validate_uniqueness <- function(d, record_id_name = "record_id", stop_on_error = variables <- intersect(colnames(d), plumbing) d_replicates <- - d |> + d %>% dplyr::count( !!!rlang::parse_exprs(variables), name = "count_of_records" - ) |> + ) %>% dplyr::filter(1L < count_of_records) if (nrow(d_replicates) == 0L) { @@ -359,8 +359,8 @@ validate_uniqueness <- function(d, record_id_name = "record_id", stop_on_error = paste(d_replicates, collapse = "\n") # nocov } - "There are %i record(s) that violate the uniqueness requirement:\n%s" |> - sprintf(nrow(d_replicates), m) |> + "There are %i record(s) that violate the uniqueness requirement:\n%s" %>% + sprintf(nrow(d_replicates), m) %>% stop() } else { indices <- paste(which(colnames(d) == variables), collapse = ", ") diff --git a/tests/testthat/test-arm-export.R b/tests/testthat/test-arm-export.R index b64d88eb..fe824484 100644 --- a/tests/testthat/test-arm-export.R +++ b/tests/testthat/test-arm-export.R @@ -9,7 +9,7 @@ read_arms <- function(path) { arm_num = readr::col_integer(), name = readr::col_character() ) - full_path |> + full_path %>% readr::read_csv(col_types = col_types) %>% dplyr::select( arm_number = "arm_num", diff --git a/tests/testthat/test-event-read.R b/tests/testthat/test-event-read.R index ee17647e..85fd4477 100644 --- a/tests/testthat/test-event-read.R +++ b/tests/testthat/test-event-read.R @@ -13,7 +13,7 @@ retrieve_expected_events <- function(path) { event_id = readr::col_integer() ) - full_path |> + full_path %>% readr::read_csv(col_types = col_types) } diff --git a/tests/testthat/test-project-info-read.R b/tests/testthat/test-project-info-read.R index f3cb761f..f50e467f 100644 --- a/tests/testthat/test-project-info-read.R +++ b/tests/testthat/test-project-info-read.R @@ -48,13 +48,13 @@ test_that("all-test-projects", { server_locale <- readr::locale(tz = "America/Chicago") returned_object <- - system.file("misc/example.credentials", package = "REDCapR") |> + system.file("misc/example.credentials", package = "REDCapR") %>% readr::read_csv( comment = "#", col_select = c(redcap_uri, token), col_types = readr::cols(.default = readr::col_character()), - ) |> - dplyr::filter(32L == nchar(token)) |> + ) %>% + dplyr::filter(32L == nchar(token)) %>% purrr::pmap_dfr( REDCapR::redcap_project_info_read, locale = server_locale, diff --git a/tests/testthat/test-validate-no-logical.R b/tests/testthat/test-validate-no-logical.R index 8fbcd1e5..1d80ecef 100644 --- a/tests/testthat/test-validate-no-logical.R +++ b/tests/testthat/test-validate-no-logical.R @@ -43,9 +43,9 @@ test_that("repeat-instance: no column", { # test_that("repeat-instance: good integer", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> -# readr::read_csv(show_col_types = FALSE) |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% +# readr::read_csv(show_col_types = FALSE) %>% # dplyr::mutate( # redcap_repeat_instance = as.integer(redcap_repeat_instance), # ) @@ -55,8 +55,8 @@ test_that("repeat-instance: no column", { # }) # test_that("repeat-instance: bad double", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # ds_1 <- validate_repeat_instance(d) @@ -74,8 +74,8 @@ test_that("repeat-instance: no column", { # # test_that("repeat-instance: bad double -stop on error", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # expect_error( diff --git a/tests/testthat/test-validate-repeat.R b/tests/testthat/test-validate-repeat.R index 36f7b96e..1f4c5830 100644 --- a/tests/testthat/test-validate-repeat.R +++ b/tests/testthat/test-validate-repeat.R @@ -7,7 +7,7 @@ test_that("validate_repeat_instance: no column", { test_that("validate_repeat_instance: good", { d <- - mtcars |> + mtcars %>% dplyr::mutate( redcap_repeat_instance = sample(1:100, size = 32, replace = TRUE) ) diff --git a/tests/testthat/test-validate.R b/tests/testthat/test-validate.R index 921f1543..a0762c20 100644 --- a/tests/testthat/test-validate.R +++ b/tests/testthat/test-validate.R @@ -49,9 +49,9 @@ test_that("not a data.frame", { # test_that("repeat-instance: good integer", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> -# readr::read_csv(show_col_types = FALSE) |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% +# readr::read_csv(show_col_types = FALSE) %>% # dplyr::mutate( # redcap_repeat_instance = as.integer(redcap_repeat_instance), # ) @@ -61,8 +61,8 @@ test_that("not a data.frame", { # }) # test_that("repeat-instance: bad double", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # ds_1 <- validate_repeat_instance(d) @@ -80,8 +80,8 @@ test_that("not a data.frame", { # # test_that("repeat-instance: bad double -stop on error", { # d <- -# "test-data/vignette-repeating-write/data-block-matrix.csv" |> -# system.file(package = "REDCapR") |> +# "test-data/vignette-repeating-write/data-block-matrix.csv" %>% +# system.file(package = "REDCapR") %>% # readr::read_csv(show_col_types = FALSE) # # expect_error(