Skip to content

Commit

Permalink
Merge pull request #57 from rnabioco/resub
Browse files Browse the repository at this point in the history
update for resubmission
  • Loading branch information
sheridar authored Jun 23, 2022
2 parents a675616 + 4fb7b3f commit c87b583
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 57 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
^docs$
^pkgdown$
^cran-comments\.md$
^CRAN-RELEASE$
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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
Expand All @@ -30,7 +30,8 @@ Depends:
R (>= 4.0.0)
Imports:
ggplot2,
grid
grid,
rlang
Suggests:
covr,
knitr,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ importFrom(grid,gpar)
importFrom(grid,grobName)
importFrom(grid,grobTree)
importFrom(grid,pointsGrob)
importFrom(rlang,on_load)
2 changes: 2 additions & 0 deletions R/geom-point-trace.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
""
}
Expand All @@ -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 {
""
}
Expand Down
17 changes: 7 additions & 10 deletions R/ggtrace-package.R
Original file line number Diff line number Diff line change
@@ -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 \email{ryan.sheridan@@cuanschutz.edu}
#'
#' \url{https://github.com/rnabioco/ggtrace}
#' @seealso Report issues and suggest improvements at \url{https://github.com/rnabioco/ggtrace/issues}
#'
#' @name ggtrace
#' @docType package
Expand All @@ -24,5 +20,6 @@
#' pointsGrob
#' grobName
#' grobTree
#' @importFrom rlang on_load
#' @keywords internal
"_PACKAGE"
52 changes: 34 additions & 18 deletions R/utilities-ggplot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -264,7 +282,6 @@ rd_aesthetics <- function(type, name) {
)

aes <- rd_aesthetics_item(obj)

aes <- aes[aes != paste0("\\code{", KEEP_CLMN, "}")]

res <- c(
Expand Down Expand Up @@ -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))
}
Expand All @@ -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
}
Expand Down
8 changes: 8 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 6 additions & 27 deletions man/ggtrace.Rd

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

0 comments on commit c87b583

Please sign in to comment.