From 7387ad50802ada59ceebab25597012c684b52612 Mon Sep 17 00:00:00 2001 From: Ezra Porter <60618324+ezraporter@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:29:24 -0400 Subject: [PATCH] fix CI --- DESCRIPTION | 2 +- R/clean_redcap_long.R | 2 +- R/supertibble.R | 6 +- man/REDCapTidieR-package.Rd | 2 +- man/as_supertbl.Rd | 2 +- man/tbl_sum.redcap_supertbl.Rd | 21 ++++ man/vec_ptype_abbr.redcap_supertbl.Rd | 25 +++++ pkgdown/_pkgdown.yml | 4 + renv.lock | 9 +- renv/activate.R | 39 ++++++-- tests/testthat/_snaps/supertibble.md | 4 +- tests/testthat/_snaps/write.md | 134 +++++++++++++------------- 12 files changed, 159 insertions(+), 91 deletions(-) create mode 100644 man/tbl_sum.redcap_supertbl.Rd create mode 100644 man/vec_ptype_abbr.redcap_supertbl.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 3781bdb3..c637efa4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,5 +51,5 @@ Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE) diff --git a/R/clean_redcap_long.R b/R/clean_redcap_long.R index 56402796..a65fded6 100644 --- a/R/clean_redcap_long.R +++ b/R/clean_redcap_long.R @@ -85,7 +85,7 @@ clean_redcap_long <- function(db_data_long, # Retrieve mixed structure fields and forms in reference df mixed_structure_ref <- get_mixed_structure_fields(db_data_long) %>% filter(.data$rep_and_nonrep & !str_ends(.data$field_name, "_form_complete")) %>% - left_join(db_metadata_long %>% select(.data$field_name, .data$form_name), + left_join(db_metadata_long %>% select("field_name", "form_name"), by = "field_name" ) diff --git a/R/supertibble.R b/R/supertibble.R index 073cdef2..f849f53b 100644 --- a/R/supertibble.R +++ b/R/supertibble.R @@ -13,12 +13,14 @@ as_supertbl <- function(x) { x } +#' @inherit vctrs::vec_ptype_abbr params return title description #' @export -vec_ptype_abbr.redcap_supertbl <- function(x) { +vec_ptype_abbr.redcap_supertbl <- function(x, ..., prefix_named, suffix_shape) { "suprtbl" } +#' @inherit pillar::tbl_sum params return title description #' @export tbl_sum.redcap_supertbl <- function(x) { - paste("A REDCapTidier Supertibble with", nrow(x), "instruments") + paste("A REDCapTidieR Supertibble with", nrow(x), "instruments") } diff --git a/man/REDCapTidieR-package.Rd b/man/REDCapTidieR-package.Rd index f4c8120e..4e55422f 100644 --- a/man/REDCapTidieR-package.Rd +++ b/man/REDCapTidieR-package.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/REDCapTidieR-package.R \docType{package} \name{REDCapTidieR-package} +\alias{REDCapTidieR} \alias{REDCapTidieR-package} -\alias{_PACKAGE} \title{REDCapTidieR: Extract 'REDCap' Databases into Tidy 'Tibble's} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} diff --git a/man/as_supertbl.Rd b/man/as_supertbl.Rd index bd317197..de84b85d 100644 --- a/man/as_supertbl.Rd +++ b/man/as_supertbl.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_redcap.R +% Please edit documentation in R/supertibble.R \name{as_supertbl} \alias{as_supertbl} \title{Add supertbl S3 class} diff --git a/man/tbl_sum.redcap_supertbl.Rd b/man/tbl_sum.redcap_supertbl.Rd new file mode 100644 index 00000000..b56ba302 --- /dev/null +++ b/man/tbl_sum.redcap_supertbl.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/supertibble.R +\name{tbl_sum.redcap_supertbl} +\alias{tbl_sum.redcap_supertbl} +\title{Provide a succinct summary of an object} +\usage{ +\method{tbl_sum}{redcap_supertbl}(x) +} +\arguments{ +\item{x}{Object to summarise.} +} +\value{ +A named character vector, describing the dimensions in the first element +and the data source in the name of the first element. +} +\description{ +\code{tbl_sum()} gives a brief textual description of a table-like object, +which should include the dimensions and the data source in the first element, +and additional information in the other elements (such as grouping for \pkg{dplyr}). +The default implementation forwards to \code{\link[pillar:obj_sum]{obj_sum()}}. +} diff --git a/man/vec_ptype_abbr.redcap_supertbl.Rd b/man/vec_ptype_abbr.redcap_supertbl.Rd new file mode 100644 index 00000000..f0c7833e --- /dev/null +++ b/man/vec_ptype_abbr.redcap_supertbl.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/supertibble.R +\name{vec_ptype_abbr.redcap_supertbl} +\alias{vec_ptype_abbr.redcap_supertbl} +\title{Vector type as a string} +\usage{ +\method{vec_ptype_abbr}{redcap_supertbl}(x, ..., prefix_named, suffix_shape) +} +\arguments{ +\item{x}{A vector.} + +\item{...}{These dots are for future extensions and must be empty.} + +\item{prefix_named}{If \code{TRUE}, add a prefix for named vectors.} + +\item{suffix_shape}{If \code{TRUE} (the default), append the shape of +the vector.} +} +\value{ +A string. +} +\description{ +\code{vec_ptype_full()} displays the full type of the vector. \code{vec_ptype_abbr()} +provides an abbreviated summary suitable for use in a column heading. +} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index dbed8408..7801c4fe 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -67,3 +67,7 @@ reference: - title: "Data" contents: - superheroes_supertbl +- title: "S3 methods" + contents: + - tbl_sum.redcap_supertbl + - vec_ptype_abbr.redcap_supertbl diff --git a/renv.lock b/renv.lock index 6a3fccd3..5b0207ee 100644 --- a/renv.lock +++ b/renv.lock @@ -1436,13 +1436,8 @@ }, "renv": { "Package": "renv", - "Version": "1.0.3", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "utils" - ], - "Hash": "41b847654f567341725473431dd0d5ab" + "Version": "1.0.5", + "Source": "Repository" }, "repr": { "Package": "repr", diff --git a/renv/activate.R b/renv/activate.R index cb5401f9..9b2e7f18 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,7 +2,7 @@ local({ # the requested version of renv - version <- "1.0.3" + version <- "1.0.5" attr(version, "sha") <- NULL # the project directory @@ -31,6 +31,14 @@ local({ if (!is.null(override)) return(override) + # if we're being run in a context where R_LIBS is already set, + # don't load -- presumably we're being run as a sub-process and + # the parent process has already set up library paths for us + rcmd <- Sys.getenv("R_CMD", unset = NA) + rlibs <- Sys.getenv("R_LIBS", unset = NA) + if (!is.na(rlibs) && !is.na(rcmd)) + return(FALSE) + # next, check environment variables # TODO: prefer using the configuration one in the future envvars <- c( @@ -50,9 +58,22 @@ local({ }) - if (!enabled) + # bail if we're not enabled + if (!enabled) { + + # if we're not enabled, we might still need to manually load + # the user profile here + profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile") + if (file.exists(profile)) { + cfg <- Sys.getenv("RENV_CONFIG_USER_PROFILE", unset = "TRUE") + if (tolower(cfg) %in% c("true", "t", "1")) + sys.source(profile, envir = globalenv()) + } + return(FALSE) + } + # avoid recursion if (identical(getOption("renv.autoloader.running"), TRUE)) { warning("ignoring recursive attempt to run renv autoloader") @@ -1041,7 +1062,7 @@ local({ # if jsonlite is loaded, use that instead if ("jsonlite" %in% loadedNamespaces()) { - json <- catch(renv_json_read_jsonlite(file, text)) + json <- tryCatch(renv_json_read_jsonlite(file, text), error = identity) if (!inherits(json, "error")) return(json) @@ -1050,7 +1071,7 @@ local({ } # otherwise, fall back to the default JSON reader - json <- catch(renv_json_read_default(file, text)) + json <- tryCatch(renv_json_read_default(file, text), error = identity) if (!inherits(json, "error")) return(json) @@ -1063,14 +1084,14 @@ local({ } renv_json_read_jsonlite <- function(file = NULL, text = NULL) { - text <- paste(text %||% read(file), collapse = "\n") + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") jsonlite::fromJSON(txt = text, simplifyVector = FALSE) } renv_json_read_default <- function(file = NULL, text = NULL) { # find strings in the JSON - text <- paste(text %||% read(file), collapse = "\n") + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' locs <- gregexpr(pattern, text, perl = TRUE)[[1]] @@ -1118,14 +1139,14 @@ local({ map <- as.list(map) # remap strings in object - remapped <- renv_json_remap(json, map) + remapped <- renv_json_read_remap(json, map) # evaluate eval(remapped, envir = baseenv()) } - renv_json_remap <- function(json, map) { + renv_json_read_remap <- function(json, map) { # fix names if (!is.null(names(json))) { @@ -1152,7 +1173,7 @@ local({ # recurse if (is.recursive(json)) { for (i in seq_along(json)) { - json[i] <- list(renv_json_remap(json[[i]], map)) + json[i] <- list(renv_json_read_remap(json[[i]], map)) } } diff --git a/tests/testthat/_snaps/supertibble.md b/tests/testthat/_snaps/supertibble.md index 352a9ba1..1aaa5694 100644 --- a/tests/testthat/_snaps/supertibble.md +++ b/tests/testthat/_snaps/supertibble.md @@ -1,9 +1,9 @@ # supertibble prints with style Code - as_supertbl(tibble(redcap_form_name = letters[1:5], redcap_data = list(NULL))) + . Output - # A REDCapTidier Supertibble with 5 instruments + # A REDCapTidieR Supertibble with 5 instruments redcap_form_name redcap_data 1 a diff --git a/tests/testthat/_snaps/write.md b/tests/testthat/_snaps/write.md index e9620fae..7c011037 100644 --- a/tests/testthat/_snaps/write.md +++ b/tests/testthat/_snaps/write.md @@ -115,12 +115,12 @@ 4 Unchecked Checked 5 Unchecked Unchecked 6 Unchecked Unchecked - NA NA NA NA - 2 checkbox_multiple_2___4eeee5 yesno NA signature - 3 Unchecked yes FALSE signature_2022-08-02_1114.png - 4 Unchecked NA - 5 Unchecked NA - 6 Unchecked NA + NA NA NA NA + 2 checkbox_multiple_2___4eeee5 yesno truefalse signature + 3 Unchecked yes FALSE signature_2022-08-02_1114.png + 4 Unchecked + 5 Unchecked + 6 Unchecked NA NA 2 fileupload slider 3 gas_receipt_20220729.jpeg 73 @@ -1246,73 +1246,73 @@ 67 68 Histogram Is the Categorical Value Ordered? Count of Unique Values - 2 numeric.hist NA factor.n_unique - 3 NA - 4 NA - 5 NA - 6 ▇▁▁▁▇ NA - 7 ▇▁▁▁▇ NA - 8 NA - 9 NA - 10 NA - 11 NA - 12 ▁▁▇▁▁ NA + 2 numeric.hist factor.ordered factor.n_unique + 3 + 4 + 5 + 6 ▇▁▁▁▇ + 7 ▇▁▁▁▇ + 8 + 9 + 10 + 11 + 12 ▁▁▇▁▁ 13 FALSE 2 14 FALSE 2 15 FALSE 0 - 16 NA - 17 NA - 18 NA - 19 NA - 20 NA - 21 NA - 22 NA - 23 NA - 24 NA - 25 NA - 26 NA - 27 NA - 28 NA - 29 NA - 30 NA - 31 NA - 32 NA - 33 NA - 34 NA - 35 NA - 36 NA - 37 ▁▁▇▁▁ NA + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 ▁▁▇▁▁ 38 FALSE 0 - 39 NA - 40 NA - 41 NA - 42 NA - 43 NA - 44 NA - 45 NA - 46 NA - 47 NA - 48 NA - 49 NA - 50 NA - 51 NA - 52 NA - 53 NA - 54 NA - 55 NA - 56 NA - 57 NA - 58 NA - 59 NA + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 60 FALSE 2 - 61 NA - 62 NA - 63 NA - 64 NA + 61 + 62 + 63 + 64 65 FALSE 2 - 66 NA - 67 NA - 68 NA + 66 + 67 + 68 Most Frequent Values Proportion of TRUE Values Count of Logical Values 2 factor.top_counts logical.mean logical.count 3