From ba174a240857b69215f1047f6d4fb59986bd020e Mon Sep 17 00:00:00 2001 From: elimillera Date: Fri, 28 Jan 2022 14:18:35 +0000 Subject: [PATCH] Updates for CRAN comments --- NAMESPACE | 1 - R/pkg_ref_class.R | 5 ++--- R/utils.R | 34 ------------------------------- R/utils_memoised.R | 7 ------- R/zzz.R | 1 - cran-comments.md | 4 ++++ man/capture_expr_output.Rd | 23 --------------------- man/suppressMatchingConditions.Rd | 14 ------------- 8 files changed, 6 insertions(+), 83 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 90f94ce5..2ca513dc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -132,7 +132,6 @@ importFrom(utils,available.packages) importFrom(utils,capture.output) importFrom(utils,getS3method) importFrom(utils,head) -importFrom(utils,installed.packages) importFrom(utils,packageDescription) importFrom(utils,packageName) importFrom(utils,packageVersion) diff --git a/R/pkg_ref_class.R b/R/pkg_ref_class.R index a43da155..1750e5a9 100644 --- a/R/pkg_ref_class.R +++ b/R/pkg_ref_class.R @@ -266,7 +266,7 @@ as_pkg_ref.pkg_ref <- function(x, ...) { } -#' @importFrom utils installed.packages available.packages packageVersion +#' @importFrom utils available.packages packageVersion #' @export as_pkg_ref.character <- function(x, repos = getOption("repos", "https://cran.rstudio.com"), source = NULL, lib.loc = NULL, ...) { @@ -302,9 +302,8 @@ determine_pkg_source <- function(x, source, repos) { # non-source package } else if (grepl("^[[:alpha:]][[:alnum:].]*[[:alnum:]]$", x)) { - ip <- memoise_installed_packages() - if (x %in% ip[, "Package"]) { + if (length(find.package(x, quiet = TRUE)) != 0) { return("pkg_install") # if its not installed, pull the package to check it diff --git a/R/utils.R b/R/utils.R index 581e56c0..919c728f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -100,27 +100,6 @@ firstS3method <- function(f, classes, envir = parent.frame()) { #' Defaults to \code{FALSE}, capturing the passed expression. #' @inheritParams base::sink #' -#' @examples -#' fn <- function() { -#' print(paste(letters[1:3], collapse = ", ")) -#' warning("easy as") -#' message(paste(1:3, collapse = ", ")) -#' message("simple as") -#' warning("do re mi") -#' return(3L) -#' } -#' -#' capture_expr_output <- utils::getFromNamespace("capture_expr_output", "riskmetric") -#' console_output <- capture_expr_output(fn()) -#' -#' # console_output -#' # > fn() -#' # [1] "a, b, c" -#' # Warning in fn(): easy as -#' # 1, 2, 3 -#' # simple as -#' # Warning in fn(): do re mi -#' # [1] 3 #' #' @importFrom utils head tail #' @return an with_eval_recording object @@ -303,19 +282,6 @@ print.with_eval_recording <- function(x, playback = FALSE, cr = TRUE, ..., #' condition. #' @param .opts A named list of arguments to pass to \code{grepl} #' @param .envir The environment in which \code{expr} is to be evaluated -#' @examples -#' riskmetric:::suppressMatchingConditions({ -#' print(paste(letters[1:3], collapse = ", ")) -#' warning(structure( -#' list(message = "easy as", call = NULL), -#' class = c("custom_warning", "warning", "condition"))) -#' message(paste(1:3, collapse = ", ")) -#' message("simple as") -#' warning("do re mi") -#' }, -#' message = "\\d", -#' custom_warning = "as$", -#' warning = "\\w{2}\\s") #' @return a message printed on console #' @keywords internal suppressMatchingConditions <- function(expr, ..., .opts = list(), diff --git a/R/utils_memoised.R b/R/utils_memoised.R index 1f29b7aa..d734447b 100644 --- a/R/utils_memoised.R +++ b/R/utils_memoised.R @@ -67,13 +67,6 @@ memoise_bioc_mirrors <- memoise::memoise({ -#' @importFrom memoise memoise -memoise_installed_packages <- memoise::memoise({ - function(...) utils::installed.packages(...) -}) - - - #' @importFrom memoise memoise memoise_available_packages <- memoise::memoise({ Sys.sleep(20) diff --git a/R/zzz.R b/R/zzz.R index bdfd53c6..98516fe6 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -18,6 +18,5 @@ # if non-interactive, cache package sources on load if (!interactive()) { memoise_available_packages() - memoise_installed_packages() } } diff --git a/cran-comments.md b/cran-comments.md index 5c9d29e2..5c8c06c1 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,7 @@ +## Submission 2 + +Per comments from Gregor Seyer, the use of installed.packages was replaced with find.package. Examples for unexported functions were also removed. + ## Test environments * local R installation, R 3.6.2 * local R installation, R 3.6.2 diff --git a/man/capture_expr_output.Rd b/man/capture_expr_output.Rd index 62768889..4af2c30d 100644 --- a/man/capture_expr_output.Rd +++ b/man/capture_expr_output.Rd @@ -26,28 +26,5 @@ an with_eval_recording object \description{ All messaging condition side effects are captured in the order that they are issued. -} -\examples{ -fn <- function() { - print(paste(letters[1:3], collapse = ", ")) - warning("easy as") - message(paste(1:3, collapse = ", ")) - message("simple as") - warning("do re mi") - return(3L) -} - -capture_expr_output <- utils::getFromNamespace("capture_expr_output", "riskmetric") -console_output <- capture_expr_output(fn()) - -# console_output -# > fn() -# [1] "a, b, c" -# Warning in fn(): easy as -# 1, 2, 3 -# simple as -# Warning in fn(): do re mi -# [1] 3 - } \keyword{internal} diff --git a/man/suppressMatchingConditions.Rd b/man/suppressMatchingConditions.Rd index 1e1d875a..2b22ce75 100644 --- a/man/suppressMatchingConditions.Rd +++ b/man/suppressMatchingConditions.Rd @@ -24,18 +24,4 @@ a message printed on console \description{ Suppress messages and warnings based on one or more regex matches } -\examples{ -riskmetric:::suppressMatchingConditions({ - print(paste(letters[1:3], collapse = ", ")) - warning(structure( - list(message = "easy as", call = NULL), - class = c("custom_warning", "warning", "condition"))) - message(paste(1:3, collapse = ", ")) - message("simple as") - warning("do re mi") - }, - message = "\\\\d", - custom_warning = "as$", - warning = "\\\\w{2}\\\\s") -} \keyword{internal}