diff --git a/DESCRIPTION b/DESCRIPTION index 77ba1bd..17525ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,26 @@ Package: ggalt Title: Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2' -Version: 0.0.3.9000 +Version: 0.0.4.9000 Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre"))) -Description: A package containing additional/alternate 'geoms', 'coords' and 'stats' - for use with the revamped (late 2015) version of ggplot2. -Depends: R (>= 3.0.0), ggplot2 (>= 1.0.1.9003) +Description: A package containing additional/alternate 'geoms', 'coords' and + 'stats' for use with the revamped (late 2015) version of ggplot2. +Depends: + R (>= 3.0.0), + ggplot2 (>= 1.0.1.9003) License: AGPL + file LICENSE LazyData: true -Suggests: testthat, gridExtra +Suggests: + testthat, + gridExtra Encoding: UTF-8 -Imports: graphics, grDevices, dplyr, KernSmooth, proj4, scales, grid, gtable, ash +Imports: + graphics, + grDevices, + dplyr, + KernSmooth, + proj4, + scales, + grid, + gtable, + ash +RoxygenNote: 5.0.0 diff --git a/NAMESPACE b/NAMESPACE index 5c92d5c..6ac0273 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2 (4.1.1): do not edit by hand +# Generated by roxygen2: do not edit by hand S3method(grid.draw,absoluteGrob) S3method(grobHeight,absoluteGrob) diff --git a/R/geom_ash.r b/R/geom_ash.r index 5f0f836..05b2495 100644 --- a/R/geom_ash.r +++ b/R/geom_ash.r @@ -57,7 +57,7 @@ stat_ash <- function(mapping = NULL, data = NULL, geom = "area", position = "stack", ab = NULL, nbin = 50, m = 5, kopt = c(2, 2), - show.legend = NA, inherit.aes = TRUE, ...) { + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( data = data, @@ -68,6 +68,7 @@ stat_ash <- function(mapping = NULL, data = NULL, geom = "area", show.legend = show.legend, inherit.aes = inherit.aes, params = list( + na.rm = na.rm, ab = ab, nbin = nbin, m = m, diff --git a/R/geom_bkde.r b/R/geom_bkde.r index 45526b1..4a9d163 100644 --- a/R/geom_bkde.r +++ b/R/geom_bkde.r @@ -15,17 +15,16 @@ #' \item \code{linetype} #' \item \code{size} #' } -#' +#' @inheritParams ggplot2::geom_point #' @param geom,stat Use to override the default connection between #' \code{geom_bkde} and \code{stat_bkde}. #' @seealso See \code{\link{geom_histogram}}, \code{\link{geom_freqpoly}} for #' other methods of displaying continuous distribution. #' See \code{\link{geom_violin}} for a compact density display. -#' @inheritParams ggplot2::geom_point #' @export geom_bkde <- function(mapping = NULL, data = NULL, stat = "bkde", position = "identity", bandwidth=NULL, range.x=NULL, - show.legend = NA, inherit.aes = TRUE, + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( @@ -38,6 +37,7 @@ geom_bkde <- function(mapping = NULL, data = NULL, stat = "bkde", inherit.aes = inherit.aes, params = list(bandwidth=bandwidth, range.x=range.x, + na.rm=na.rm, ...) ) } @@ -93,7 +93,7 @@ GeomBkde <- ggproto("GeomBkde", GeomArea, stat_bkde <- function(mapping = NULL, data = NULL, geom = "area", position = "stack", kernel="normal", canonical=FALSE, bandwidth = NULL, gridsize=410, range.x=NULL, - truncate=TRUE, show.legend = NA, inherit.aes = TRUE, + truncate=TRUE, na.rm=FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( @@ -111,6 +111,7 @@ stat_bkde <- function(mapping = NULL, data = NULL, geom = "area", gridsize=gridsize, range.x=range.x, truncate=truncate, + na.rm=na.rm, ... ) ) @@ -129,7 +130,7 @@ StatBkde <- ggproto("StatBkde", Stat, compute_group = function(data, scales, kernel="normal", canonical=FALSE, bandwidth=NULL, gridsize=410, range.x=NULL, - truncate=TRUE) { + truncate=TRUE, na.rm = TRUE) { # KernSmooth::dpik uses a generated normal distribution as part of it's # operation but doesn't do this seed save/create/restore. When bandwidth @@ -152,14 +153,14 @@ StatBkde <- ggproto("StatBkde", Stat, compute_bkde(data$x, kernel=kernel, canonical=canonical, bandwidth=bandwidth, gridsize=gridsize, range.x=range.x, - truncate=truncate) + truncate=truncate, na.rm) } ) compute_bkde <- function(x, kernel="normal", canonical=FALSE, - bandwidth, gridsize=410, range.x, truncate=TRUE) { + bandwidth, gridsize=410, range.x, truncate=TRUE, na.rm=TRUE) { n <- length(x) @@ -170,7 +171,7 @@ compute_bkde <- function(x, kernel="normal", canonical=FALSE, data.frame( x = dens$x, density = dens$y, - scaled = dens$y / max(dens$y, na.rm = TRUE), + scaled = dens$y / max(dens$y, na.rm = na.rm), count = dens$y * n, n = n ) diff --git a/R/geom_bkde2d.r b/R/geom_bkde2d.r index e7f3e04..dadc69a 100644 --- a/R/geom_bkde2d.r +++ b/R/geom_bkde2d.r @@ -32,7 +32,7 @@ geom_bkde2d <- function(mapping = NULL, data = NULL, stat = "bkde2d", position = "identity", bandwidth=NULL, range.x=NULL, lineend = "butt", contour=TRUE, linejoin = "round", linemitre = 1, - show.legend = NA, + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( data = data, @@ -48,6 +48,7 @@ geom_bkde2d <- function(mapping = NULL, data = NULL, stat = "bkde2d", linemitre = linemitre, bandwidth = bandwidth, range.x = range.x, + na.rm = na.rm, ... ) ) @@ -92,7 +93,7 @@ GeomBkde2d <- ggproto("GeomBkde2d", GeomPath, stat_bkde2d <- function(mapping = NULL, data = NULL, geom = "density2d", position = "identity", contour = TRUE, bandwidth=NULL, grid_size=c(51, 51), range.x=NULL, - truncate=TRUE, show.legend = NA, + truncate=TRUE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( data = data, @@ -108,6 +109,7 @@ stat_bkde2d <- function(mapping = NULL, data = NULL, geom = "density2d", range.x = range.x, truncate = truncate, contour = contour, + na.rm = na.rm, ... ) ) diff --git a/R/geom_xspline.r b/R/geom_xspline.r index 3e23c06..6548800 100644 --- a/R/geom_xspline.r +++ b/R/geom_xspline.r @@ -108,8 +108,8 @@ #' geom_smooth(se=FALSE, linetype="dashed", size=0.5) + #' geom_xspline(spline_shape=-1, size=0.5) geom_xspline <- function(mapping = NULL, data = NULL, stat = "xspline", - position = "identity", show.legend = NA, - inherit.aes = TRUE, na.rm = TRUE, + position = "identity", na.rm = TRUE, show.legend = NA, + inherit.aes = TRUE, spline_shape=-0.25, open=TRUE, rep_ends=TRUE, ...) { layer( geom = GeomXspline, @@ -121,6 +121,7 @@ geom_xspline <- function(mapping = NULL, data = NULL, stat = "xspline", inherit.aes = inherit.aes, params = list(spline_shape=spline_shape, open=open, + na.rm = na.rm, rep_ends=rep_ends, ...) ) @@ -147,7 +148,7 @@ GeomXspline <- ggproto("GeomXspline", GeomLine, #' \item{y} #' } stat_xspline <- function(mapping = NULL, data = NULL, geom = "line", - position = "identity", show.legend = NA, inherit.aes = TRUE, + position = "identity", na.rm = TRUE, show.legend = NA, inherit.aes = TRUE, spline_shape=-0.25, open=TRUE, rep_ends=TRUE, ...) { layer( stat = StatXspline, @@ -159,6 +160,7 @@ stat_xspline <- function(mapping = NULL, data = NULL, geom = "line", inherit.aes = inherit.aes, params = list(spline_shape=spline_shape, open=open, + na.rm = na.rm, rep_ends=rep_ends, ... ) diff --git a/README.Rmd b/README.Rmd index a7c4405..b6584a4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -10,7 +10,7 @@ output: knitr::opts_chunk$set( collapse = TRUE, comment = "#>", - fig.retina = 2, +fig.retina = 2, fig.path = "README_figs/README-" ) ``` diff --git a/README.md b/README.md index 96266b2..c132fb2 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ library(ggalt) # current verison packageVersion("ggalt") -#> [1] '0.0.3.9000' +#> [1] '0.0.4.9000' set.seed(1492) dat <- data.frame(x=c(1:10, 1:10, 1:10), @@ -256,6 +256,10 @@ ggplot(geyser_dat, aes(x, y)) + ``` r # devtools::install_github("hrbrmstr/ggplot2") world <- map_data("world") +#> +#> # ATTENTION: maps v3.0 has an updated 'world' map. # +#> # Many country borders and names have changed since 1990. # +#> # Type '?world' or 'news(package="maps")'. See README_v3. # world <- world[world$region != "Antarctica",] gg <- ggplot() @@ -274,13 +278,11 @@ library(ggalt) library(testthat) date() -#> [1] "Sun Sep 13 07:33:03 2015" +#> [1] "Sat Oct 31 10:07:15 2015" test_dir("tests/") #> testthat results ======================================================================================================== #> OK: 0 SKIPPED: 0 FAILED: 0 -#> -#> DONE ``` ### Code of Conduct diff --git a/README_figs/README-bkde_ash-5.png b/README_figs/README-bkde_ash-5.png index c46a280..5be6c99 100644 Binary files a/README_figs/README-bkde_ash-5.png and b/README_figs/README-bkde_ash-5.png differ diff --git a/README_figs/README-coord_proj-1.png b/README_figs/README-coord_proj-1.png index 192b9f1..d95260f 100644 Binary files a/README_figs/README-coord_proj-1.png and b/README_figs/README-coord_proj-1.png differ diff --git a/README_figs/README-splines-3.png b/README_figs/README-splines-3.png index 7c5294b..4dc4b09 100644 Binary files a/README_figs/README-splines-3.png and b/README_figs/README-splines-3.png differ diff --git a/README_figs/README-splines-4.png b/README_figs/README-splines-4.png index b4f9e5a..539a18a 100644 Binary files a/README_figs/README-splines-4.png and b/README_figs/README-splines-4.png differ diff --git a/README_figs/README-splines-5.png b/README_figs/README-splines-5.png index 0eca048..9a06b79 100644 Binary files a/README_figs/README-splines-5.png and b/README_figs/README-splines-5.png differ diff --git a/README_figs/README-splines-6.png b/README_figs/README-splines-6.png index a683d49..2b1b767 100644 Binary files a/README_figs/README-splines-6.png and b/README_figs/README-splines-6.png differ diff --git a/README_figs/README-splines-7.png b/README_figs/README-splines-7.png index 4e77bd0..b135f9f 100644 Binary files a/README_figs/README-splines-7.png and b/README_figs/README-splines-7.png differ diff --git a/README_figs/README-splines-8.png b/README_figs/README-splines-8.png index feae3cf..d63883f 100644 Binary files a/README_figs/README-splines-8.png and b/README_figs/README-splines-8.png differ diff --git a/man/absoluteGrob.Rd b/man/absoluteGrob.Rd index b3a0b8a..f45ca9d 100644 --- a/man/absoluteGrob.Rd +++ b/man/absoluteGrob.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/grob_absolute.r \name{absoluteGrob} \alias{absoluteGrob} diff --git a/man/coord_proj.Rd b/man/coord_proj.Rd index f04284a..44ffb55 100644 --- a/man/coord_proj.Rd +++ b/man/coord_proj.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/coord_proj.r \name{coord_proj} \alias{coord_proj} diff --git a/man/geom_bkde.Rd b/man/geom_bkde.Rd index ec98993..8e7e208 100644 --- a/man/geom_bkde.Rd +++ b/man/geom_bkde.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/geom_bkde.r \name{geom_bkde} \alias{geom_bkde} @@ -7,12 +7,12 @@ \usage{ geom_bkde(mapping = NULL, data = NULL, stat = "bkde", position = "identity", bandwidth = NULL, range.x = NULL, - show.legend = NA, inherit.aes = TRUE, ...) + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) stat_bkde(mapping = NULL, data = NULL, geom = "area", position = "stack", kernel = "normal", canonical = FALSE, bandwidth = NULL, gridsize = 410, range.x = NULL, truncate = TRUE, - show.legend = NA, inherit.aes = TRUE, ...) + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) } \arguments{ \item{mapping}{Set of aesthetic mappings created by \code{\link{aes}} or @@ -35,6 +35,9 @@ results.} \item{range.x}{vector containing the minimum and maximum values of x at which to compute the estimate. see \code{\link[KernSmooth]{bkde}} for details} +\item{na.rm}{If \code{FALSE} (the default), removes missing values with +a warning. If \code{TRUE} silently removes missing values.} + \item{show.legend}{logical. Should this layer be included in the legends? \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes.} @@ -55,7 +58,7 @@ the default plot specification, e.g. \code{\link{borders}}.} \item Other arguments passed on to the stat. }} -\item{geom,stat}{Use to override the default connection between +\item{geom, stat}{Use to override the default connection between \code{geom_bkde} and \code{stat_bkde}.} \item{kernel}{character string which determines the smoothing kernel. see diff --git a/man/geom_bkde2d.Rd b/man/geom_bkde2d.Rd index 73865f8..f17aa92 100644 --- a/man/geom_bkde2d.Rd +++ b/man/geom_bkde2d.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/geom_bkde2d.r \name{geom_bkde2d} \alias{geom_bkde2d} @@ -8,11 +8,11 @@ geom_bkde2d(mapping = NULL, data = NULL, stat = "bkde2d", position = "identity", bandwidth = NULL, range.x = NULL, lineend = "butt", contour = TRUE, linejoin = "round", linemitre = 1, - show.legend = NA, inherit.aes = TRUE, ...) + na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) stat_bkde2d(mapping = NULL, data = NULL, geom = "density2d", position = "identity", contour = TRUE, bandwidth = NULL, - grid_size = c(51, 51), range.x = NULL, truncate = TRUE, + grid_size = c(51, 51), range.x = NULL, truncate = TRUE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) } \arguments{ @@ -49,6 +49,9 @@ estimation} \item{linemitre}{Line mitre limit (number greater than 1)} +\item{na.rm}{If \code{FALSE} (the default), removes missing values with +a warning. If \code{TRUE} silently removes missing values.} + \item{show.legend}{logical. Should this layer be included in the legends? \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes.} diff --git a/man/geom_xspline.Rd b/man/geom_xspline.Rd index cfe5893..f45b212 100644 --- a/man/geom_xspline.Rd +++ b/man/geom_xspline.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/geom_xspline.r \name{geom_xspline} \alias{geom_xspline} @@ -6,12 +6,14 @@ \title{Connect control points/observations with an X-spline} \usage{ geom_xspline(mapping = NULL, data = NULL, stat = "xspline", - position = "identity", show.legend = NA, inherit.aes = TRUE, - na.rm = TRUE, spline_shape = -0.25, open = TRUE, rep_ends = TRUE, ...) + position = "identity", na.rm = TRUE, show.legend = NA, + inherit.aes = TRUE, spline_shape = -0.25, open = TRUE, + rep_ends = TRUE, ...) stat_xspline(mapping = NULL, data = NULL, geom = "line", - position = "identity", show.legend = NA, inherit.aes = TRUE, - spline_shape = -0.25, open = TRUE, rep_ends = TRUE, ...) + position = "identity", na.rm = TRUE, show.legend = NA, + inherit.aes = TRUE, spline_shape = -0.25, open = TRUE, + rep_ends = TRUE, ...) } \arguments{ \item{mapping}{Set of aesthetic mappings created by \code{\link{aes}} or @@ -26,6 +28,9 @@ defined at the top level of the plot.} \item{position}{Position adjustment, either as a string, or the result of a call to a position adjustment function.} +\item{na.rm}{If \code{FALSE} (the default), removes missing values with +a warning. If \code{TRUE} silently removes missing values.} + \item{show.legend}{logical. Should this layer be included in the legends? \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes.} @@ -35,9 +40,6 @@ 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. \code{\link{borders}}.} -\item{na.rm}{If \code{FALSE} (the default), removes missing values with -a warning. If \code{TRUE} silently removes missing values.} - \item{spline_shape}{A numeric vector of values between -1 and 1, which control the shape of the spline relative to the control points.} @@ -59,7 +61,7 @@ curve. Ignored for closed X-splines.} \item Other arguments passed on to the stat. }} -\item{geom,stat}{Use to override the default connection between +\item{geom, stat}{Use to override the default connection between \code{geom_xspline} and \code{stat_xspline}.} } \description{ diff --git a/man/ggalt-ggproto.Rd b/man/ggalt-ggproto.Rd index 1a58ab8..249da4e 100644 --- a/man/ggalt-ggproto.Rd +++ b/man/ggalt-ggproto.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/geom_bkde.r, R/geom_bkde2d.r, R/geom_xspline.r \docType{data} \name{GeomBkde} diff --git a/man/ggalt.Rd b/man/ggalt.Rd index 388f3f9..d99009e 100644 --- a/man/ggalt.Rd +++ b/man/ggalt.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggalt-package.r \docType{package} \name{ggalt} diff --git a/man/stat_ash.Rd b/man/stat_ash.Rd index 1ecbacd..7da1ae1 100644 --- a/man/stat_ash.Rd +++ b/man/stat_ash.Rd @@ -1,12 +1,12 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/geom_ash.r \name{stat_ash} \alias{stat_ash} \title{Compute and display a univariate averaged shifted histogram (polynomial kernel)} \usage{ stat_ash(mapping = NULL, data = NULL, geom = "area", position = "stack", - ab = NULL, nbin = 50, m = 5, kopt = c(2, 2), show.legend = NA, - inherit.aes = TRUE, ...) + ab = NULL, nbin = 50, m = 5, kopt = c(2, 2), na.rm = FALSE, + show.legend = NA, inherit.aes = TRUE, ...) } \arguments{ \item{mapping}{Set of aesthetic mappings created by \code{\link{aes}} or @@ -35,6 +35,9 @@ interval.} to \emph{( 1 - abs(i/m)^kopt(1) )i^kopt(2)}; (2,2)=biweight (default); (0,0)=uniform; (1,0)=triangle; (2,1)=Epanechnikov; (2,3)=triweight.} +\item{na.rm}{If \code{FALSE} (the default), removes missing values with +a warning. If \code{TRUE} silently removes missing values.} + \item{show.legend}{logical. Should this layer be included in the legends? \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes.}