OuhscBbmc / REDCapR

Compare 6147117 ... +47 ... f079d9d

Showing 17 of 69 files from the diff.
Other files ignored by Codecov
NEWS.md has changed.
inst/WORDLIST has changed.
NAMESPACE has changed.
_pkgdown.yml has changed.
utility/refresh.R has changed.

@@ -13,7 +13,7 @@
Loading
13 13
#' @param perl Indicates if perl-compatible regexps should be used.
14 14
#'   Default is `TRUE`. Optional.
15 15
#'
16 -
#' @return Currently, a [base::data.frame()] is returned a row for each match,
16 +
#' @return Currently, a [tibble::tibble()] is returned a row for each match,
17 17
#' and a column for each *named* group within a match.  For the
18 18
#' `retrieve_checkbox_choices()` function, the columns will be.
19 19
#' * `id`: The numeric value assigned to each choice (in the data dictionary).
@@ -22,13 +22,17 @@
Loading
22 22
#' @details
23 23
#' The [regex_named_captures()] function is general, and not specific to
24 24
#' REDCap; it accepts any arbitrary regular expression.
25 -
#' It returns a [base::data.frame()] with as many columns as named matches.
25 +
#' It returns a [tibble::tibble()] with as many columns as named matches.
26 26
#'
27 27
#' The [checkbox_choices()] function is specialized, and accommodates the
28 28
#' "select choices" for a *single* REDCap checkbox group (where multiple boxes
29 -
#' can be selected).  It returns a [base::data.frame()] with two columns, one
29 +
#' can be selected).  It returns a [tibble::tibble()] with two columns, one
30 30
#' for the numeric id and one for the text label.
31 31
#'
32 +
#' The parse will probably fail if a label contains a pipe (*i.e.*, `|`),
33 +
#' since that the delimiter REDCap uses to separate choices
34 +
#' presented to the user.
35 +
#'
32 36
#' @author Will Beasley
33 37
#' @references See the official documentation for permissible characters in a
34 38
#' checkbox label.
@@ -59,7 +63,7 @@
Loading
59 63
#' token       <- "9A81268476645C4E5F03428B8AC3AA7B"
60 64
#'
61 65
#' ds_metadata <- redcap_metadata_read(redcap_uri=uri, token=token)$data
62 -
#' choices_2   <- ds_metadata[ds_metadata$field_name=="race", "select_choices_or_calculations"]
66 +
#' choices_2   <- ds_metadata[ds_metadata$field_name=="race", ]$select_choices_or_calculations
63 67
#'
64 68
#' REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_2)
65 69
#' }
@@ -70,15 +74,14 @@
Loading
70 74
#' REDCapR::regex_named_captures(pattern=pattern_boxes, text=choices_3)
71 75
72 76
#' @export
73 -
regex_named_captures <- function(pattern, text, perl=TRUE) {
74 -
77 +
regex_named_captures <- function(pattern, text, perl = TRUE) {
75 78
  checkmate::assert_character(pattern, any.missing=FALSE, min.chars=0L, len=1)
76 79
  checkmate::assert_character(text   , any.missing=FALSE, min.chars=0L, len=1)
77 80
  checkmate::assert_logical(  perl   , any.missing=FALSE)
78 81
79 82
  match <- gregexpr(pattern, text, perl = perl)[[1]]
80 83
  capture_names <- attr(match, "capture.names")
81 -
  d <- as.data.frame(matrix(
84 +
  d <- base::data.frame(matrix(
82 85
    data  = NA_character_,
83 86
    nrow  = length(attr(match, "match.length")),
84 87
    ncol  = length(capture_names)
@@ -95,7 +98,7 @@
Loading
95 98
      attr(match, "capture.length")[, column_name]
96 99
    )
97 100
  }
98 -
  d
101 +
  tibble::as_tibble(d)
99 102
}
100 103
101 104
#' @rdname metadata_utilities

@@ -10,7 +10,7 @@
Loading
10 10
# This function isn't used during testing itself.  Just to create the expected file.
11 11
save_expected <- function(o, path) {
12 12
  # nocov start
13 -
  attr(returned_object$data, which = "problems") <- NULL
13 +
  attr(o, which = "problems") <- NULL
14 14
  path <- file.path("inst", path)
15 15
  if (!dir.exists(dirname(path))) dir.create(dirname(path), recursive = FALSE)
16 16

@@ -32,7 +32,7 @@
Loading
32 32
#' @author Will Beasley
33 33
#'
34 34
#' @seealso
35 -
#' See [redcap_read()] for a function that uses `create_batch_gloassary`.
35 +
#' See [redcap_read()] for a function that uses `create_batch_glossary`.
36 36
#'
37 37
#' @examples
38 38
#' REDCapR::create_batch_glossary(100, 50)

@@ -22,7 +22,7 @@
Loading
22 22
#' `httr` package.  See the details below. Optional.
23 23
#'
24 24
#' @return Currently, a list is returned with the following elements,
25 -
#' * `data`: An R [base::data.frame()] where each row represents one column
25 +
#' * `data`: A [tibble::tibble()] where each row represents one column
26 26
#' in the REDCap dataset.
27 27
#' * `success`: A boolean value indicating if the operation was apparently
28 28
#' successful.
@@ -119,7 +119,7 @@
Loading
119 119
    } else {
120 120
      # nocov start
121 121
      kernel$success  <- FALSE # Override the 'success' http status code.
122 -
      ds              <- data.frame() #Return an empty data.frame
122 +
      ds              <- tibble::tibble() # Return an empty data.frame
123 123
124 124
      outcome_message <- sprintf(
125 125
        "The REDCap variable retrieval failed.  The http status code was %i.  The 'raw_text' returned was '%s'.",
@@ -129,7 +129,7 @@
Loading
129 129
      # nocov end
130 130
    }
131 131
  } else {
132 -
    ds              <- data.frame() #Return an empty data.frame
132 +
    ds              <- tibble::tibble() # Return an empty data.frame
133 133
    outcome_message <- if (any(grepl(kernel$regex_empty, kernel$raw_text))) {
134 134
      "The REDCapR read/export operation was not successful.  The returned dataset (of instrument-events) was empty."
135 135
    } else {

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 1 files with coverage changes found.

New file R/redcap-metadata-coltypes.R
New
Loading file...

49 Commits

Hiding 1 contexual commits
Hiding 1 contexual commits
+25
+25
-1
-1
+10
+10
Hiding 2 contexual commits
-4
-4
Hiding 6 contexual commits
+1 Files
+144
+144
Hiding 7 contexual commits
Hiding 1 contexual commits
Hiding 3 contexual commits Hiding 1 contexual commits Hiding 1 contexual commits Hiding 1 contexual commits Hiding 4 contexual commits
Hiding 2 contexual commits
-4
-4
Files Coverage
R 0.32% 95.99%
Project Totals (40 files) 95.99%
Loading