Skip to content

Commit

Permalink
replace native pipes for now
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Jul 13, 2023
1 parent 56f11f9 commit abb9100
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
12 changes: 6 additions & 6 deletions R/validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand All @@ -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 = ", ")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-arm-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-event-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-project-info-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-validate-no-logical.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
# )
Expand All @@ -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)
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-validate-repeat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
# )
Expand All @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit abb9100

Please sign in to comment.