From 990f92a55a04d14dfe3c7948ae76fa174f833e45 Mon Sep 17 00:00:00 2001 From: Jay Hesselberth Date: Sun, 29 Aug 2021 05:28:44 -0600 Subject: [PATCH] Updates for CMD CHECK --- DESCRIPTION | 32 ++++++++-------- NAMESPACE | 23 +++--------- R/geom_point_trace.R | 15 +++++--- R/ggtrace-package.R | 28 ++++++++++++++ R/utils-tidy-eval.R | 47 ------------------------ README.Rmd | 1 + man/geom_point_trace.Rd | 6 +-- man/ggplot2-ggproto.Rd | 10 +++++ man/ggtrace.Rd | 30 +++++++++++++++ man/tidyeval.Rd | 51 -------------------------- tests/testthat.R | 4 ++ tests/testthat/test-geom_point_trace.R | 3 ++ 12 files changed, 109 insertions(+), 141 deletions(-) create mode 100644 R/ggtrace-package.R delete mode 100644 R/utils-tidy-eval.R create mode 100644 man/ggplot2-ggproto.Rd create mode 100644 man/ggtrace.Rd delete mode 100644 man/tidyeval.Rd create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-geom_point_trace.R diff --git a/DESCRIPTION b/DESCRIPTION index 0d0460b..7914c3a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,23 +1,25 @@ -Package: ggtrace Type: Package -Title: Trace Data Points +Package: ggtrace +Title: Trace groups of geoms from 'ggplot2' Version: 0.0.0.9000 Authors@R: - c(person(given = "Ryan", - family = "Sheridan", - role = c("aut", "cre"), - email = "ryan.sheridan@cuanschutz.edu", - comment = c(ORCID = "0000-0003-4012-3147"))) -Description: A geom to outline groups of data points + person(given = "Ryan", + family = "Sheridan", + role = c("aut", "cre"), + email = "ryan.sheridan@cuanschutz.edu", + comment = c(ORCID = "0000-0003-4012-3147")) +Description: Provides a geom for 'ggplot2' that improves the clarity of + plots with many overlapping geoms. License: MIT + file LICENSE -Encoding: UTF-8 -LazyData: true -Imports: - ggplot2, - grid, - rlang -RoxygenNote: 7.1.1 Depends: R (>= 4.0.0) +Imports: + ggplot2, + grid Suggests: + testthat (>= 3.0.0), covr +Encoding: UTF-8 +LazyData: true +RoxygenNote: 7.1.1 +Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 56d7d23..002c5c3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,22 +1,9 @@ # Generated by roxygen2: do not edit by hand -export(":=") -export(.data) export(GeomPointTrace) -export(as_label) -export(as_name) -export(enquo) -export(enquos) -export(expr) export(geom_point_trace) -export(sym) -export(syms) -importFrom(rlang,":=") -importFrom(rlang,.data) -importFrom(rlang,as_label) -importFrom(rlang,as_name) -importFrom(rlang,enquo) -importFrom(rlang,enquos) -importFrom(rlang,expr) -importFrom(rlang,sym) -importFrom(rlang,syms) +import(ggplot2) +importFrom(grid,gpar) +importFrom(grid,grobName) +importFrom(grid,grobTree) +importFrom(grid,pointsGrob) diff --git a/R/geom_point_trace.R b/R/geom_point_trace.R index 026b4ed..e911b59 100644 --- a/R/geom_point_trace.R +++ b/R/geom_point_trace.R @@ -1,4 +1,4 @@ -#' Highlight points +#' Trace points to improve clarity of plots with overplotted geoms. #' #' @param mapping Set of aesthetic mappings created by [aes()] or #' [aes_()]. If specified and `inherit.aes = TRUE` (the @@ -18,7 +18,6 @@ #' the plot data. The return value must be a `data.frame`, and #' will be used as the layer data. A `function` can be created #' from a `formula` (e.g. `~ head(.x, 10)`). -#' @param geom The geometric object to use display the data #' @param stat The statistical transformation to use on the data for this #' layer, as a string. #' @param position Position adjustment, either as a string, or the result of @@ -41,6 +40,7 @@ #' rather than combining with them. This is most useful for helper functions #' that define both data and aesthetics and shouldn't inherit behaviour from #' the default plot specification, e.g. [borders()]. +#' @rdname geom_point_trace #' @export # https://stackoverflow.com/questions/67573707/ggplot-extension-function-to-plot-a-superimposed-mean-in-a-scatterplot geom_point_trace <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", @@ -66,6 +66,7 @@ geom_point_trace <- function(mapping = NULL, data = NULL, stat = "identity", pos ) } +#' GeomPointTrace #' @rdname ggplot2-ggproto #' @format NULL #' @usage NULL @@ -143,7 +144,8 @@ GeomPointTrace <- ggplot2::ggproto( draw_key = ggplot2::draw_key_point ) -# Helper to adjust shape specification +#' Helper to adjust shape specification +#' @noRd translate_trace_shape <- function(pch) { pch_tbl <- c( "0" = 0, # "square open" @@ -195,9 +197,10 @@ translate_trace_shape <- function(pch) { res } -# Name ggplot grid object -# Helper to name grid objects -# https://github.com/tidyverse/ggplot2/blob/master/R/utilities-grid.r +#' Name ggplot grid object +#' Helper to name grid objects +#' https://github.com/tidyverse/ggplot2/blob/master/R/utilities-grid.r +#' @noRd ggname <- function(prefix, grob) { grob$name <- grid::grobName(grob, prefix) grob diff --git a/R/ggtrace-package.R b/R/ggtrace-package.R new file mode 100644 index 0000000..4d7cf02 --- /dev/null +++ b/R/ggtrace-package.R @@ -0,0 +1,28 @@ +#' ggtrace +#' +#' This package contains extra geoms for \pkg{ggplot2}. +#' +#' Please see the help pages listed below: +#' +#' \itemize{ +#' \item \code{\link{geom_point_trace}} +#' } +#' +#' Also see the vignette for more usage examples: +#' +#' \code{browseVignettes("ggtrace")} +#' +#' Please report issues and suggest improvements at Github: +#' +#' \url{https://github.com/rnabioco/ggtrace} +#' +#' @name ggtrace +#' @docType package +#' @import ggplot2 +#' @importFrom grid +#' gpar +#' pointsGrob +#' grobName +#' grobTree +#' @keywords internal +"_PACKAGE" diff --git a/R/utils-tidy-eval.R b/R/utils-tidy-eval.R deleted file mode 100644 index b4e6c7f..0000000 --- a/R/utils-tidy-eval.R +++ /dev/null @@ -1,47 +0,0 @@ -#' Tidy eval helpers -#' -#' @description -#' -#' * \code{\link[rlang]{sym}()} creates a symbol from a string and -#' \code{\link[rlang:sym]{syms}()} creates a list of symbols from a -#' character vector. -#' -#' * \code{\link[rlang:nse-defuse]{enquo}()} and -#' \code{\link[rlang:nse-defuse]{enquos}()} delay the execution of one or -#' several function arguments. \code{enquo()} returns a single quoted -#' expression, which is like a blueprint for the delayed computation. -#' \code{enquos()} returns a list of such quoted expressions. -#' -#' * \code{\link[rlang:nse-defuse]{expr}()} quotes a new expression _locally_. It -#' is mostly useful to build new expressions around arguments -#' captured with [enquo()] or [enquos()]: -#' \code{expr(mean(!!enquo(arg), na.rm = TRUE))}. -#' -#' * \code{\link[rlang]{as_name}()} transforms a quoted variable name -#' into a string. Supplying something else than a quoted variable -#' name is an error. -#' -#' That's unlike \code{\link[rlang]{as_label}()} which also returns -#' a single string but supports any kind of R object as input, -#' including quoted function calls and vectors. Its purpose is to -#' summarise that object into a single label. That label is often -#' suitable as a default name. -#' -#' If you don't know what a quoted expression contains (for instance -#' expressions captured with \code{enquo()} could be a variable -#' name, a call to a function, or an unquoted constant), then use -#' \code{as_label()}. If you know you have quoted a simple variable -#' name, or would like to enforce this, use \code{as_name()}. -#' -#' To learn more about tidy eval and how to use these tools, visit -#' \url{https://tidyeval.tidyverse.org} and the -#' \href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming -#' section} of \href{https://adv-r.hadley.nz}{Advanced R}. -#' -#' @md -#' @name tidyeval -#' @keywords internal -#' @importFrom rlang expr enquo enquos sym syms .data := as_name as_label -#' @aliases expr enquo enquos sym syms .data := as_name as_label -#' @export expr enquo enquos sym syms .data := as_name as_label -NULL diff --git a/README.Rmd b/README.Rmd index 41cbf43..10fee15 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,6 +18,7 @@ knitr::opts_chunk$set( [![Codecov test coverage](https://codecov.io/gh/rnabioco/ggoutline/branch/master/graph/badge.svg)](https://codecov.io/gh/rnabioco/ggoutline?branch=master) +[![R-CMD-check](https://github.com/rnabioco/ggtrace/workflows/R-CMD-check/badge.svg)](https://github.com/rnabioco/ggtrace/actions) ## Installation diff --git a/man/geom_point_trace.Rd b/man/geom_point_trace.Rd index 40ff4cc..b8bb87e 100644 --- a/man/geom_point_trace.Rd +++ b/man/geom_point_trace.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/geom_point_trace.R \name{geom_point_trace} \alias{geom_point_trace} -\title{Highlight points} +\title{Trace points to improve clarity of plots with overplotted geoms.} \usage{ geom_point_trace( mapping = NULL, @@ -65,9 +65,7 @@ display.} rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. [borders()].} - -\item{geom}{The geometric object to use display the data} } \description{ -Highlight points +Trace points to improve clarity of plots with overplotted geoms. } diff --git a/man/ggplot2-ggproto.Rd b/man/ggplot2-ggproto.Rd new file mode 100644 index 0000000..a81f840 --- /dev/null +++ b/man/ggplot2-ggproto.Rd @@ -0,0 +1,10 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/geom_point_trace.R +\docType{data} +\name{GeomPointTrace} +\alias{GeomPointTrace} +\title{GeomPointTrace} +\description{ +GeomPointTrace +} +\keyword{datasets} diff --git a/man/ggtrace.Rd b/man/ggtrace.Rd new file mode 100644 index 0000000..1db2b4a --- /dev/null +++ b/man/ggtrace.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ggtrace-package.R +\docType{package} +\name{ggtrace} +\alias{ggtrace} +\alias{ggtrace-package} +\title{ggtrace} +\description{ +This package contains extra geoms for \pkg{ggplot2}. +} +\details{ +Please see the help pages listed below: + +\itemize{ + \item \code{\link{geom_point_trace}} +} + +Also see the vignette for more usage examples: + +\code{browseVignettes("ggtrace")} + +Please report issues and suggest improvements at Github: + +\url{https://github.com/rnabioco/ggtrace} +} +\author{ +\strong{Maintainer}: Ryan Sheridan \email{ryan.sheridan@cuanschutz.edu} (\href{https://orcid.org/0000-0003-4012-3147}{ORCID}) + +} +\keyword{internal} diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd deleted file mode 100644 index ebcd89a..0000000 --- a/man/tidyeval.Rd +++ /dev/null @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils-tidy-eval.R -\name{tidyeval} -\alias{tidyeval} -\alias{expr} -\alias{enquo} -\alias{enquos} -\alias{sym} -\alias{syms} -\alias{.data} -\alias{:=} -\alias{as_name} -\alias{as_label} -\title{Tidy eval helpers} -\description{ -\itemize{ -\item \code{\link[rlang]{sym}()} creates a symbol from a string and -\code{\link[rlang:sym]{syms}()} creates a list of symbols from a -character vector. -\item \code{\link[rlang:nse-defuse]{enquo}()} and -\code{\link[rlang:nse-defuse]{enquos}()} delay the execution of one or -several function arguments. \code{enquo()} returns a single quoted -expression, which is like a blueprint for the delayed computation. -\code{enquos()} returns a list of such quoted expressions. -\item \code{\link[rlang:nse-defuse]{expr}()} quotes a new expression \emph{locally}. It -is mostly useful to build new expressions around arguments -captured with \code{\link[=enquo]{enquo()}} or \code{\link[=enquos]{enquos()}}: -\code{expr(mean(!!enquo(arg), na.rm = TRUE))}. -\item \code{\link[rlang]{as_name}()} transforms a quoted variable name -into a string. Supplying something else than a quoted variable -name is an error. - -That's unlike \code{\link[rlang]{as_label}()} which also returns -a single string but supports any kind of R object as input, -including quoted function calls and vectors. Its purpose is to -summarise that object into a single label. That label is often -suitable as a default name. - -If you don't know what a quoted expression contains (for instance -expressions captured with \code{enquo()} could be a variable -name, a call to a function, or an unquoted constant), then use -\code{as_label()}. If you know you have quoted a simple variable -name, or would like to enforce this, use \code{as_name()}. -} - -To learn more about tidy eval and how to use these tools, visit -\url{https://tidyeval.tidyverse.org} and the -\href{https://adv-r.hadley.nz/metaprogramming.html}{Metaprogramming -section} of \href{https://adv-r.hadley.nz}{Advanced R}. -} -\keyword{internal} diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..cb8dad3 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(ggtrace) + +test_check("ggtrace") diff --git a/tests/testthat/test-geom_point_trace.R b/tests/testthat/test-geom_point_trace.R new file mode 100644 index 0000000..34c412b --- /dev/null +++ b/tests/testthat/test-geom_point_trace.R @@ -0,0 +1,3 @@ +test_that("unexpected args throw warning", { + expect_warning(ggplot() + geom_point_trace(blah = "blerg")) +})