Skip to content

Commit

Permalink
Merge pull request #499 from OuhscBbmc/dev
Browse files Browse the repository at this point in the history
Handle leading space in REDCap checkbox options (into main branch)
  • Loading branch information
wibeasley authored Jul 14, 2023
2 parents 0d69b0e + 53bc3e1 commit 1bdde82
Show file tree
Hide file tree
Showing 24 changed files with 194 additions and 114 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ This will help extract forms from longitudinal & repeating projects.
* `validate_repeat_instance()`
* `validate_no_logical()`
* `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493)
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495)
Version 1.1.0 (released 2022-08-10)
==========================================================
Expand Down
2 changes: 1 addition & 1 deletion R/constant.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#'
#' The current constants relate to the 'complete' variable at the
#' end of each form.
#' * `form_incomplete`: 0L (*i.e.*, an integer)
#' * `form_incomplete`: 0L (_i.e._, an integer)
#' * `form_unverified`: 1L
#' * `form_complete`: 2L
#'
Expand Down
4 changes: 2 additions & 2 deletions R/create-batch-glossary.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ create_batch_glossary <- function(row_count, batch_size) {

start_index <- as.integer(base::seq.int(from=1L, to=row_count, by=batch_size))

ds_batch <-
ds_batch <-
tibble::tibble(
id = seq_along(start_index),
start_index = start_index
)
ds_batch$stop_index <-
ds_batch$stop_index <-
base::mapply(
function(i) {
base::ifelse(
Expand Down
17 changes: 8 additions & 9 deletions R/kernel-api.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
#' token <- "9A81268476645C4E5F03428B8AC3AA7B"
#' post_body <- list(
#' token = token,
#' content = 'project',
#' format = 'csv'
#' content = "project",
#' format = "csv"
#' )
#' \dontrun{
#' kernel <- REDCapR:::kernel_api(uri, post_body, config_options)
#'
#' # Consume the results in a few different ways.
#' kernel$result
#' read.csv(text=kernel$raw_text)
#' as.list(read.csv(text=kernel$raw_text))
#' read.csv(text = kernel$raw_text)
#' as.list(read.csv(text = kernel$raw_text))
#' }

kernel_api <- function(
Expand Down Expand Up @@ -83,9 +83,9 @@ kernel_api <- function(
httr::user_agent("OuhscBbmc/REDCapR")
)

status_code <- response$status
success <- (status_code == 200L)
raw_text <- httr::content(
status_code <- response$status
success <- (status_code == 200L)
raw_text <- httr::content(
x = response,
as = "text",
encoding = encoding, # UTF-8 is the default parameter value
Expand All @@ -104,7 +104,7 @@ kernel_api <- function(
any(grepl(regex_cannot_connect, raw_text)) #||
# any(grepl(regex_empty , raw_text))
) {
success <- FALSE # nocov
success <- FALSE # nocov
}

return(list(
Expand All @@ -114,7 +114,6 @@ kernel_api <- function(
elapsed_seconds = elapsed_seconds,
result = response,
result_headers = response$headers,

regex_empty = regex_empty
))
}
8 changes: 4 additions & 4 deletions R/metadata-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@

#' @export
regex_named_captures <- function(pattern, text, perl = TRUE) {
checkmate::assert_character(pattern, any.missing=FALSE, min.chars=0L, len=1)
checkmate::assert_character(text , any.missing=FALSE, min.chars=0L, len=1)
checkmate::assert_logical( perl , any.missing=FALSE)
checkmate::assert_character(pattern, any.missing = FALSE, len = 1, min.chars = 0L)
checkmate::assert_character(text , any.missing = FALSE, len = 1, min.chars = 0L)
checkmate::assert_logical( perl , any.missing = FALSE, len = 1 )

match <- gregexpr(pattern, text, perl = perl)[[1]]
capture_names <- attr(match, "capture.names")
Expand Down Expand Up @@ -114,7 +114,7 @@ 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)

pattern_checkboxes <- "(?<=\\A| \\| )(?<id>\\d{1,}), (?<label>[^|]{1,})(?= \\| |\\Z)"
pattern_checkboxes <- "(?<=\\A| \\| |\\| )(?<id>\\d{1,}), (?<label>[^|]{1,}?)(?= \\| |\\| |\\Z)"

regex_named_captures(pattern = pattern_checkboxes, text = select_choices)
}
4 changes: 2 additions & 2 deletions R/redcap-metadata-coltypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ redcap_metadata_internal <- function(

if (is.na(d_proj$has_repeating_instruments_or_events[1])) { # nocov start
# Don't test coverage for this block b/c it only executes for old versions of REDCap
stop(
error_message <-
sprintf(
paste(
"The REDCap instance at %s failed to report if the",
"current project uses repeatable instruments or events."
),
redcap_uri
)
)
stop(error_message)
} # nocov end

if (d_proj$has_repeating_instruments_or_events[1]) {
Expand Down
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
48 changes: 27 additions & 21 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,61 @@
Description
===============================================

This submission is primarily to address a recent change in the REDCap server.
This submission is primarily to address a change in the REDCap server. A lot of packages additions in the meantime were building up.

Thank you for taking the time to review my submission, and please tell me if there's something else I should do for CRAN. -Will Beasley

Test environments
-----------------------------------------------

1. Local Ubuntu, R 4.2.2
2. Local Win10, R 4.2.3 patched
2. Local Win11, R 4.3.1 patched
3. R-hub
1. [Ubuntu Linux 20.04 LTS, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-aa1d5ab8d07d453db1f07927d1ad23f4)
2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-a56bc6477bbb48d2a4aa5d1872481dac)
3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-34917c524b674b82860b920d177844f1)
4. [win-builder](https://win-builder.r-project.org/eG6x3HZ9ITqN), development version.
5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 20.04 LTS
1. [Ubuntu Linux, R-release, GCC](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-746e237d11914129b4410114fbfa2c83)
2. [Fedora Linux, R-devel, clang, gfortran](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-e695d8a48601419e8059863cc80964b7)
3. [Windows Server](https://builder.r-hub.io/status/REDCapR_1.1.9005.tar.gz-c30d344462dc43a4b03e68a33be664d9)
4. [win-builder](https://win-builder.r-project.org/0u5J1JiksFZg/), development version.
5. [GiHub Actions](https://github.com/OuhscBbmc/REDCapR/actions), Ubuntu 22.04 LTS

R CMD check results
-----------------------------------------------

* No ERRORs or WARNINGs on any builds.

* A NOTE is returned for a few websites. All are accessible by browser.
* <https://community.projectredcap.org> is a site accessible only to REDCap administrators
* <https://grantome.com/grant/NIH/P01-AG043362>
* <https://grantome.com/grant/NIH/U54-GM104938>
* <https://taggs.hhs.gov/Detail/AwardDetail?arg_AwardNum=U54GM104938&arg_ProgOfficeCode=127>
* <https://www.researchgate.net/profile/William-Beasley-5>

* There is one NOTE that is only found on R-hub Windows (Server 2022, R-devel 64-bit):
* There are two NOTEs across the R-hub builds:

```txt
* checking for detritus in the temp directory ... NOTE
Found the following files/directories:
'lastMiKTeXException'
As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored.
```

* There is one NOTE that is only found on the R-hub Fedora:
As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored.

```txt
* checking HTML version of manual ... NOTE
Skipping checking HTML validation: no command 'tidy' found
```

Based on [this discussion](https://groups.google.com/g/r-sig-mac/c/7u_ivEj4zhM?pli=1), it sounds like a problem with the testing environment, and not the package code.
Based on [this discussion](https://groups.google.com/g/r-sig-mac/c/7u_ivEj4zhM?pli=1)
and [this SO answer](https://stackoverflow.com/a/75007979/1082435),
it sounds like a problem with the testing environment and not the package code.

Downstream dependencies
-----------------------------------------------

No downstream packages are affected. The package that depends/imports/suggests REDCapR passes checks with `revdepcheck::revdep_check()`. Results: <https://github.com/OuhscBbmc/REDCapR/blob/main/revdep/cran.md>
With one exception,
packages that depend/import/suggest REDCapR pass checks with `revdepcheck::revdep_check()`.

I worked with **tidyREDCap** team and they accepted a PR that fixes the problem:
<https://github.com/RaymondBalise/tidyREDCap/pull/61>.

package | E | W | N
------- | - | - | -
codified 0.3.0 | E: 0 | W: 0 | N: 0
REDCapDM 0.7.0 | E: 0 | W: 0 | N: 1
REDCapCAST 23.6.2 | E: 0 | W: 0 | N: 0
REDCapTidieR 0.4.0 | E: 1 | W: 0 | N: 0
tidyREDCap 1.1.1 | E: 0 +1 | W: 0 | N: 0
ReviewR 2.3.8 | E: 0 | W: 0 | N: 1

* [ReviewR](https://CRAN.R-project.org/package=ReviewR)
Results: <https://github.com/OuhscBbmc/REDCapR/blob/main/revdep/cran.md>
8 changes: 4 additions & 4 deletions man/kernel_api.Rd

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

32 changes: 16 additions & 16 deletions revdep/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

|field |value |
|:--------|:------------------------------------------------|
|version |R version 4.2.3 Patched (2023-03-29 r84127 ucrt) |
|os |Windows 10 x64 (build 22621) |
|version |R version 4.3.1 Patched (2023-07-06 r84647 ucrt) |
|os |Windows 11 x64 (build 22621) |
|system |x86_64, mingw32 |
|ui |RStudio |
|language |(EN) |
|collate |English_United States.utf8 |
|ctype |English_United States.utf8 |
|tz |America/Chicago |
|date |2023-04-21 |
|rstudio |2023.03.0+386 Cherry Blossom (desktop) |
|pandoc |NA |
|date |2023-07-14 |
|rstudio |2023.06.1+524 Mountain Hydrangea (desktop) |
|pandoc |3.1.5 @ C:\PROGRA~1\Pandoc\pandoc.exe |

# Dependencies

Expand All @@ -23,19 +23,19 @@
|backports |1.4.1 |1.4.1 | |
|bit |4.0.5 |4.0.5 | |
|bit64 |4.0.5 |4.0.5 | |
|checkmate |2.1.0 |2.1.0 | |
|checkmate |2.2.0 |2.2.0 | |
|cli |3.6.1 |3.6.1 | |
|clipr |0.8.0 |0.8.0 | |
|cpp11 |0.4.3 |0.4.3 | |
|cpp11 |0.4.4 |0.4.4 | |
|crayon |1.5.2 |1.5.2 | |
|curl |5.0.0 |5.0.0 | |
|curl |5.0.1 |5.0.1 | |
|dplyr |1.1.2 |1.1.2 | |
|fansi |1.0.4 |1.0.4 | |
|generics |0.1.3 |0.1.3 | |
|glue |1.6.2 |1.6.2 | |
|hms |1.1.3 |1.1.3 | |
|httr |1.4.5 |1.4.5 | |
|jsonlite |1.8.4 |1.8.4 | |
|httr |1.4.6 |1.4.6 | |
|jsonlite |1.8.7 |1.8.7 | |
|lifecycle |1.0.3 |1.0.3 | |
|magrittr |2.0.3 |2.0.3 | |
|mime |0.12 |0.12 | |
Expand All @@ -47,17 +47,17 @@
|purrr |1.0.1 |1.0.1 | |
|R6 |2.5.1 |2.5.1 | |
|readr |2.1.4 |2.1.4 | |
|rlang |1.1.0 |1.1.0 | |
|rlang |1.1.1 |1.1.1 | |
|stringi |1.7.12 |1.7.12 | |
|stringr |1.5.0 |1.5.0 | |
|sys |3.4.1 |3.4.1 | |
|sys |3.4.2 |3.4.2 | |
|tibble |3.2.1 |3.2.1 | |
|tidyr |1.3.0 |1.3.0 | |
|tidyselect |1.2.0 |1.2.0 | |
|tzdb |0.3.0 |0.3.0 | |
|tzdb |0.4.0 |0.4.0 | |
|utf8 |1.2.3 |1.2.3 | |
|vctrs |0.6.2 |0.6.2 | |
|vroom |1.6.1 |1.6.1 | |
|vctrs |0.6.3 |0.6.3 | |
|vroom |1.6.3 |1.6.3 | |
|withr |2.5.0 |2.5.0 | |

# Revdeps
Expand All @@ -66,5 +66,5 @@

|package |version |error |warning |note |
|:----------|:-------|:------|:-------|:----|
|[tidyREDCap](problems.md#tidyredcap)|1.1.0 |__+1__ | | |
|[tidyREDCap](problems.md#tidyredcap)|1.1.1 |__+1__ | | |

2 changes: 1 addition & 1 deletion revdep/cran.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## revdepcheck results

We checked 5 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
We checked 6 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 1 new problems
* We failed to check 0 packages
Expand Down
15 changes: 8 additions & 7 deletions revdep/problems.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<details>

* Version: 1.1.0
* GitHub: <https://github.com/RaymondBalise/tidyREDCap>
* Source code: <https://github.com/cran/tidyREDCap>
* Date/Publication: 2023-02-18 18:10:02 UTC
* Number of recursive dependencies: 82
* Version: 1.1.1
* GitHub: https://github.com/RaymondBalise/tidyREDCap
* Source code: https://github.com/cran/tidyREDCap
* Date/Publication: 2023-05-29 16:30:02 UTC
* Number of recursive dependencies: 88

Run `revdepcheck::revdep_details(, "tidyREDCap")` for more info

Expand All @@ -31,8 +31,9 @@ Run `revdepcheck::revdep_details(, "tidyREDCap")` for more info
16. └─vctrs:::stop_names(...)
17. └─vctrs:::stop_vctrs(...)
18. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 4 ]
[ FAIL 1 | WARN 8 | SKIP 0 | PASS 13 ]
Error: Test failures
Execution halted
```
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
Loading

0 comments on commit 1bdde82

Please sign in to comment.