From aa5cd204ac056654fd161b03976f59c6264eb1b0 Mon Sep 17 00:00:00 2001 From: "rmsheridan@cassini" Date: Thu, 23 Jun 2022 10:52:35 -0600 Subject: [PATCH 1/4] update for resubmission --- .Rbuildignore | 1 + DESCRIPTION | 5 +++-- NAMESPACE | 1 + R/geom-point-trace.R | 2 ++ R/ggtrace-package.R | 17 ++++++-------- R/utilities-ggplot2.R | 52 ++++++++++++++++++++++++++++--------------- man/ggtrace.Rd | 33 +++++---------------------- 7 files changed, 54 insertions(+), 57 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 5fdec6a..c67a3ba 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,4 @@ ^docs$ ^pkgdown$ ^cran-comments\.md$ +^CRAN-RELEASE$ diff --git a/DESCRIPTION b/DESCRIPTION index cf78386..59755bc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,7 @@ Authors@R: comment = c(ORCID = "0000-0002-6299-179X")), person(given = "RNA Bioscience Initiative", role = c("fnd", "cph"))) -Description: Provides ggplot2 geoms that allow groups of data points to be +Description: 'ggtrace' provides 'ggplot2' geoms that allow groups of data points to be outlined or highlighted for emphasis. This is particularly useful when working with dense datasets that are prone to overplotting. License: MIT + file LICENSE @@ -30,7 +30,8 @@ Depends: R (>= 4.0.0) Imports: ggplot2, - grid + grid, + rlang Suggests: covr, knitr, diff --git a/NAMESPACE b/NAMESPACE index e6772b7..111ad34 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,3 +17,4 @@ importFrom(grid,gpar) importFrom(grid,grobName) importFrom(grid,grobTree) importFrom(grid,pointsGrob) +importFrom(rlang,on_load) diff --git a/R/geom-point-trace.R b/R/geom-point-trace.R index 36821ef..71886b8 100644 --- a/R/geom-point-trace.R +++ b/R/geom-point-trace.R @@ -332,6 +332,7 @@ translate_shape_string <- function(shape_string) { more_problems <- if (n_bad > 5) { sprintf("\n* ... and %d more problem%s", n_bad - 5, ifelse(n_bad > 6, "s", "")) + } else { "" } @@ -358,6 +359,7 @@ translate_shape_string <- function(shape_string) { more_problems <- if (n_bad > 5) { sprintf("\n* ... and %d more problem%s", n_bad - 5, ifelse(n_bad > 6, "s", "")) + } else { "" } diff --git a/R/ggtrace-package.R b/R/ggtrace-package.R index 4d7cf02..a6ac3d6 100644 --- a/R/ggtrace-package.R +++ b/R/ggtrace-package.R @@ -1,20 +1,16 @@ #' ggtrace #' -#' This package contains extra geoms for \pkg{ggplot2}. +#' This package provides \pkg{ggplot2} geoms that allow groups of data points to be +#' outlined or highlighted for emphasis. This is particularly useful when +#' working with dense datasets that are prone to overplotting. #' -#' Please see the help pages listed below: -#' -#' \itemize{ -#' \item \code{\link{geom_point_trace}} -#' } -#' -#' Also see the vignette for more usage examples: +#' See the vignette for usage examples: #' #' \code{browseVignettes("ggtrace")} #' -#' Please report issues and suggest improvements at Github: +#' @author Ryan Sheridan #' -#' \url{https://github.com/rnabioco/ggtrace} +#' @seealso Report issues and suggest improvements at \url{https://github.com/rnabioco/ggtrace/issues} #' #' @name ggtrace #' @docType package @@ -24,5 +20,6 @@ #' pointsGrob #' grobName #' grobTree +#' @importFrom rlang on_load #' @keywords internal "_PACKAGE" diff --git a/R/utilities-ggplot2.R b/R/utilities-ggplot2.R index f308f1c..b0a53c1 100644 --- a/R/utilities-ggplot2.R +++ b/R/utilities-ggplot2.R @@ -108,13 +108,17 @@ split_with_index <- function(x, f, n = max(f)) { single_value <- function(x, ...) { UseMethod("single_value") } + #' @export single_value.default <- function(x, ...) { + # This is set by id() used in creating the grouping var identical(attr(x, "n"), 1L) } + #' @export single_value.factor <- function(x, ...) { + # Panels are encoded as factor numbers and can never be missing (NA) identical(levels(x), "1") } @@ -127,6 +131,19 @@ modify_list <- function(old, new) { old } +# Info needed for rbind_dfs date/time handling +ggtrace_global <- new.env(parent = emptyenv()) + +#' @importFrom rlang on_load +#' @noRd +rlang::on_load({ + date <- Sys.Date() + ggtrace_global$date_origin <- date - unclass(date) + + time <- Sys.time() + ggtrace_global$time_origin <- time - unclass(time) +}) + #' Bind data frames together by common column names #' #' This function is akin to `plyr::rbind.fill`, `dplyr::bind_rows`, and @@ -185,6 +202,7 @@ rbind_dfs <- function(dfs) { out[[col]] <- rep(.subset2(df, col)[1][NA], total) } } + allocated[new_columns] <- TRUE if (all(allocated)) break @@ -202,19 +220,19 @@ rbind_dfs <- function(dfs) { date_col <- inherits(df[[col]], "Date") time_col <- inherits(df[[col]], "POSIXct") - # if (is_date[[col]] && !date_col) { - # out[[col]][rng] <- as.Date( - # unclass(df[[col]]), - # origin = ggplot_global$date_origin - # ) - # - # } else if (is_time[[col]] && !time_col) { - # out[[col]][rng] <- as.POSIXct( - # unclass(df[[col]]), - # origin = ggplot_global$time_origin - # ) - - if (date_col || time_col || inherits(df[[col]], "factor")) { + if (is_date[[col]] && !date_col) { + out[[col]][rng] <- as.Date( + unclass(df[[col]]), + origin = ggtrace_global$date_origin + ) + + } else if (is_time[[col]] && !time_col) { + out[[col]][rng] <- as.POSIXct( + unclass(df[[col]]), + origin = ggtrace_global$time_origin + ) + + } else if (date_col || time_col || inherits(df[[col]], "factor")) { out[[col]][rng] <- as.character(df[[col]]) } else { @@ -264,7 +282,6 @@ rd_aesthetics <- function(type, name) { ) aes <- rd_aesthetics_item(obj) - aes <- aes[aes != paste0("\\code{", KEEP_CLMN, "}")] res <- c( @@ -330,7 +347,8 @@ find_global <- function(name, env, mode = "any") { return(get(name, envir = env, mode = mode)) } - nsenv <- asNamespace("ggplot2") + nsenv <- asNamespace("ggtrace") + if (exists(name, envir = nsenv, mode = mode)) { return(get(name, envir = nsenv, mode = mode)) } @@ -344,9 +362,7 @@ find_global <- function(name, env, mode = "any") { camelize <- function(x, first = FALSE) { x <- gsub("_(.)", "\\U\\1", x, perl = TRUE) - if (first) { - x <- firstUpper(x) - } + if (first) x <- firstUpper(x) x } diff --git a/man/ggtrace.Rd b/man/ggtrace.Rd index c36be8a..2d3e2a6 100644 --- a/man/ggtrace.Rd +++ b/man/ggtrace.Rd @@ -6,40 +6,19 @@ \alias{ggtrace-package} \title{ggtrace} \description{ -This package contains extra geoms for \pkg{ggplot2}. +This package provides \pkg{ggplot2} geoms that allow groups of data points to be +outlined or highlighted for emphasis. This is particularly useful when +working with dense datasets that are prone to overplotting. } \details{ -Please see the help pages listed below: - -\itemize{ - \item \code{\link{geom_point_trace}} -} - -Also see the vignette for more usage examples: +See the vignette for usage examples: \code{browseVignettes("ggtrace")} - -Please report issues and suggest improvements at Github: - -\url{https://github.com/rnabioco/ggtrace} } \seealso{ -Useful links: -\itemize{ - \item \url{https://github.com/rnabioco/ggtrace} - \item Report bugs at \url{https://github.com/rnabioco/ggtrace/issues} -} - +Report issues and suggest improvements at \url{https://github.com/rnabioco/ggtrace/issues} } \author{ -\strong{Maintainer}: Ryan Sheridan \email{ryan.sheridan@cuanschutz.edu} (\href{https://orcid.org/0000-0003-4012-3147}{ORCID}) - -Other contributors: -\itemize{ - \item Rui Fu \email{raysinensis@gmail.com} (\href{https://orcid.org/0000-0001-8183-4549}{ORCID}) [contributor] - \item Jay Hesselberth \email{jay.hesselberth@gmail.com} (\href{https://orcid.org/0000-0002-6299-179X}{ORCID}) [contributor] - \item RNA Bioscience Initiative [funder, copyright holder] -} - +Ryan Sheridan } \keyword{internal} From aafc924ff8bbb389b437d91fb183bdd72786e598 Mon Sep 17 00:00:00 2001 From: "rmsheridan@cassini" Date: Thu, 23 Jun 2022 11:22:29 -0600 Subject: [PATCH 2/4] fix email link --- R/ggtrace-package.R | 2 +- man/ggtrace.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/ggtrace-package.R b/R/ggtrace-package.R index a6ac3d6..dcb76d1 100644 --- a/R/ggtrace-package.R +++ b/R/ggtrace-package.R @@ -8,7 +8,7 @@ #' #' \code{browseVignettes("ggtrace")} #' -#' @author Ryan Sheridan +#' @author Ryan Sheridan \email{ryan.sheridan@@cuanschutz.edu} #' #' @seealso Report issues and suggest improvements at \url{https://github.com/rnabioco/ggtrace/issues} #' diff --git a/man/ggtrace.Rd b/man/ggtrace.Rd index 2d3e2a6..0b5dcbd 100644 --- a/man/ggtrace.Rd +++ b/man/ggtrace.Rd @@ -19,6 +19,6 @@ See the vignette for usage examples: Report issues and suggest improvements at \url{https://github.com/rnabioco/ggtrace/issues} } \author{ -Ryan Sheridan +Ryan Sheridan \email{ryan.sheridan@cuanschutz.edu} } \keyword{internal} From 482b29511e3ccdba5a78f8df71e5aa051b735663 Mon Sep 17 00:00:00 2001 From: "rmsheridan@cassini" Date: Thu, 23 Jun 2022 11:30:55 -0600 Subject: [PATCH 3/4] update cran-comments.md --- cran-comments.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cran-comments.md b/cran-comments.md index bde258d..2b845ee 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,11 @@ +## Resubmission +This is a resubmission. In this version I have: + +* Fixed DESCRIPTION so package names are in single quotes +* In the initial submission I was advised to check the R/utilities-ggplot2.R + file to verify that it does not modify the .GlobalEnv. I checked this file and + confirmed that it does not modify the .GlobalEnv. + ## Test environments * Windows 10.0.20348 (on Github Actions), R 4.2.0 * macOS 11.6.6 (on Github Actions), R 4.2.0 From 4fb7b3fb609b4a5942c9e11e08e3ea4af3394ece Mon Sep 17 00:00:00 2001 From: "rmsheridan@cassini" Date: Thu, 23 Jun 2022 11:42:42 -0600 Subject: [PATCH 4/4] fixed DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 59755bc..895ff62 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,7 @@ Authors@R: comment = c(ORCID = "0000-0002-6299-179X")), person(given = "RNA Bioscience Initiative", role = c("fnd", "cph"))) -Description: 'ggtrace' provides 'ggplot2' geoms that allow groups of data points to be +Description: Provides 'ggplot2' geoms that allow groups of data points to be outlined or highlighted for emphasis. This is particularly useful when working with dense datasets that are prone to overplotting. License: MIT + file LICENSE