Browse Source

pre-CRAN submission testing

tags/v0.1.1
boB Rudis 8 years ago
parent
commit
2c1a09e83b
  1. 1
      .Rbuildignore
  2. 9
      DESCRIPTION
  3. 1
      NAMESPACE
  4. 19
      R/coord_proj.r
  5. 5
      R/geom_ash.r
  6. 2
      R/geom_bkde.r
  7. 5
      R/geom_bkde2d.r
  8. 6
      R/geom_xspline.r
  9. 4
      R/ggalt-package.r
  10. 46
      README.Rmd
  11. 284
      README.html
  12. 129
      README.md
  13. BIN
      README_figs/README-bkde2d-1.png
  14. BIN
      README_figs/README-bkde2d-2.png
  15. BIN
      README_figs/README-bkde_ash-8.png
  16. 11
      man/coord_proj.Rd
  17. 10
      man/geom_bkde2d.Rd
  18. 19
      man/ggalt-ggproto.Rd
  19. 3
      man/ggalt.Rd

1
.Rbuildignore

@ -6,3 +6,4 @@
^CONDUCT\.md$ ^CONDUCT\.md$
^README\.md$ ^README\.md$
^README_figs ^README_figs
^README\.html$

9
DESCRIPTION

@ -1,6 +1,6 @@
Package: ggalt Package: ggalt
Title: Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2' Title: Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2'
Version: 0.0.4.9000 Version: 0.1.0.9000
Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre"))) Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")))
Description: A package containing additional/alternate 'geoms', 'coords' and Description: A package containing additional/alternate 'geoms', 'coords' and
'stats' for use with the revamped (late 2015) version of ggplot2. 'stats' for use with the revamped (late 2015) version of ggplot2.
@ -13,14 +13,17 @@ Suggests:
testthat, testthat,
gridExtra gridExtra
Encoding: UTF-8 Encoding: UTF-8
Enhances: ggplot2
Imports: Imports:
graphics, graphics,
grDevices, grDevices,
dplyr, dplyr,
RColorBrewer,
KernSmooth, KernSmooth,
proj4, proj4,
scales, scales,
grid, grid,
gtable, gtable,
ash ash,
RoxygenNote: 5.0.0 MASS
RoxygenNote: 5.0.1

1
NAMESPACE

@ -28,6 +28,7 @@ import(ggplot2)
import(grDevices) import(grDevices)
import(graphics) import(graphics)
import(proj4) import(proj4)
importFrom(RColorBrewer,brewer.pal)
importFrom(grid,gList) importFrom(grid,gList)
importFrom(grid,gTree) importFrom(grid,gTree)
importFrom(grid,grid.draw) importFrom(grid,grid.draw)

19
R/coord_proj.r

@ -2,10 +2,11 @@
#' #'
#' The representation of a portion of the earth, which is approximately #' The representation of a portion of the earth, which is approximately
#' spherical, onto a flat 2D plane requires a projection. This is what #' spherical, onto a flat 2D plane requires a projection. This is what
#' \code{coord_proj} does, using the \link[proj4]{project()} function from #' \code{coord_proj} does, using the \code{proj4::project()} function from
#' the \code{proj4} package. #' the \code{proj4} package.
#' #'
#' @param proj projection definition #' @param proj projection definition. If left \code{NULL} will default to
#' a Robinson projection
#' @param inverse if \code{TRUE} inverse projection is performed (from a #' @param inverse if \code{TRUE} inverse projection is performed (from a
#' cartographic projection into lat/long), otherwise projects from #' cartographic projection into lat/long), otherwise projects from
#' lat/long into a cartographic projection. #' lat/long into a cartographic projection.
@ -20,10 +21,15 @@
#' @param xlim manually specific x limits (in degrees of longitude) #' @param xlim manually specific x limits (in degrees of longitude)
#' @param ylim manually specific y limits (in degrees of latitude) #' @param ylim manually specific y limits (in degrees of latitude)
#' @export #' @export
coord_proj <- function(proj="+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs", coord_proj <- function(proj=NULL, inverse = FALSE, degrees = TRUE,
inverse = FALSE, degrees = TRUE,
ellps.default="sphere", xlim = NULL, ylim = NULL) { ellps.default="sphere", xlim = NULL, ylim = NULL) {
if (is.null(proj)) {
proj <- paste0(c("+proj=robin +lon_0=0 +x_0=0 +y_0=0",
"+ellps=WGS84 +datum=WGS84 +units=m +no_defs"),
collapse=" ")
}
ggproto(NULL, CoordProj, ggproto(NULL, CoordProj,
proj = proj, proj = proj,
inverse = inverse, inverse = inverse,
@ -35,6 +41,11 @@ coord_proj <- function(proj="+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +da
} }
#' Geom Proto
#' @rdname ggalt-ggproto
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export #' @export
CoordProj <- ggproto("CoordProj", Coord, CoordProj <- ggproto("CoordProj", Coord,

5
R/geom_ash.r

@ -79,6 +79,11 @@ stat_ash <- function(mapping = NULL, data = NULL, geom = "area",
} }
#' Geom Proto
#' @rdname ggalt-ggproto
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export #' @export
StatAsh <- ggproto("StatAsh", Stat, StatAsh <- ggproto("StatAsh", Stat,

2
R/geom_bkde.r

@ -42,9 +42,11 @@ geom_bkde <- function(mapping = NULL, data = NULL, stat = "bkde",
) )
} }
#' Geom Proto
#' @rdname ggalt-ggproto #' @rdname ggalt-ggproto
#' @format NULL #' @format NULL
#' @usage NULL #' @usage NULL
#' @keywords internal
#' @export #' @export
GeomBkde <- ggproto("GeomBkde", GeomArea, GeomBkde <- ggproto("GeomBkde", GeomArea,
default_aes = aes(colour = NA, fill = "gray20", size = 0.5, default_aes = aes(colour = NA, fill = "gray20", size = 0.5,

5
R/geom_bkde2d.r

@ -55,9 +55,11 @@ geom_bkde2d <- function(mapping = NULL, data = NULL, stat = "bkde2d",
} }
#' Geom Proto
#' @rdname ggalt-ggproto #' @rdname ggalt-ggproto
#' @format NULL #' @format NULL
#' @usage NULL #' @usage NULL
#' @keywords internal
#' @export #' @export
GeomBkde2d <- ggproto("GeomBkde2d", GeomPath, GeomBkde2d <- ggproto("GeomBkde2d", GeomPath,
default_aes = aes(colour = "#3366FF", size = 0.5, linetype = 1, alpha = NA) default_aes = aes(colour = "#3366FF", size = 0.5, linetype = 1, alpha = NA)
@ -73,9 +75,10 @@ GeomBkde2d <- ggproto("GeomBkde2d", GeomPath,
#' \code{\link[KernSmooth]{bkde2D}} for details. If \code{NULL}, #' \code{\link[KernSmooth]{bkde2D}} for details. If \code{NULL},
#' it will be computed for you but will most likely not yield optimal #' it will be computed for you but will most likely not yield optimal
#' results. see \code{\link[KernSmooth]{bkde2D}} for details #' results. see \code{\link[KernSmooth]{bkde2D}} for details
#' @param gridsize vector containing the number of equally spaced points in each #' @param grid_size vector containing the number of equally spaced points in each
#' direction over which the density is to be estimated. see #' direction over which the density is to be estimated. see
#' \code{\link[KernSmooth]{bkde2D}} for details #' \code{\link[KernSmooth]{bkde2D}} for details
#' @param geom default geom to use with this stat
#' @param range.x a list containing two vectors, where each vector contains the #' @param range.x a list containing two vectors, where each vector contains the
#' minimum and maximum values of x at which to compute the estimate for #' minimum and maximum values of x at which to compute the estimate for
#' each direction. see \code{\link[KernSmooth]{bkde2D}} for details #' each direction. see \code{\link[KernSmooth]{bkde2D}} for details

6
R/geom_xspline.r

@ -127,17 +127,15 @@ geom_xspline <- function(mapping = NULL, data = NULL, stat = "xspline",
) )
} }
#' GeomXspline #' Geom Proto
#' @rdname ggalt-ggproto #' @rdname ggalt-ggproto
#' @format NULL #' @format NULL
#' @usage NULL #' @usage NULL
#' @keywords internal
#' @export #' @export
GeomXspline <- ggproto("GeomXspline", GeomLine, GeomXspline <- ggproto("GeomXspline", GeomLine,
required_aes = c("x", "y"), required_aes = c("x", "y"),
default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = NA) default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = NA)
) )
#' @export #' @export

4
R/ggalt-package.r

@ -1,7 +1,6 @@
#' Extra Geoms, Stats and Coords for 'ggplot2' #' Extra Geoms, Stats and Coords for 'ggplot2'
#' #'
#' A package containing additional geoms, coords and stats for the revamped #' A package containing additional geoms, coords and stats for the ggplot2 2.0+
#' (late 2015) version of ggplot2.
#' #'
#' @name ggalt #' @name ggalt
#' @docType package #' @docType package
@ -11,4 +10,5 @@
#' @importFrom grid grobName grobTree unit.c grobHeight grobWidth viewport #' @importFrom grid grobName grobTree unit.c grobHeight grobWidth viewport
#' grid.draw grobX grobY gTree gList #' grid.draw grobX grobY gTree gList
#' @importFrom gtable gtable_col gtable_height gtable_width gtable_row gtable_col #' @importFrom gtable gtable_col gtable_height gtable_width gtable_row gtable_col
#' @importFrom RColorBrewer brewer.pal
NULL NULL

46
README.Rmd

@ -1,5 +1,7 @@
--- ---
output: output:
html_document:
keep_md: true
md_document: md_document:
variant: markdown_github variant: markdown_github
--- ---
@ -17,17 +19,13 @@ fig.retina = 2,
`ggalt` : Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2' `ggalt` : Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2'
A package containing additional/alternate 'geoms', 'coords' and 'stats' for use with the revamped (late 2015) version of ggplot2. A package containing additional/alternate 'geoms', 'coords' and 'stats' for use with ggplot2 2.0+.
The first three forays into this brave, new `ggplot2` world are _splines_! and being able to use the (much better) `KernSmooth::bkde` and `KernSmooth::bkde2D` for density plots and an initial port of the (still needing work) `coord_proj`. The first three forays into this brave, new `ggplot2` world are _splines_! and being able to use the (much better) `KernSmooth::bkde` and `KernSmooth::bkde2D` for density plots and an initial port of the (still needing work) `coord_proj`.
**NOTE**
Until the new `ggplot2` version is on CRAN, you'll need to install it from github via `devtools::install_github("hrbrmstr/ggplot2")`. Locally, I have goth `ggalt` and my `ggplot2` in a "develment mode" install via `devtools::dev_mode()`. Since the new `ggplot2` breaks _many_ other packages (like `plotly`, CRAN `ggthemes`, `ggmap` and more), keeping it squirreled away in it's own area is a good idea until everyone catches up.
The following functions are implemented: The following functions are implemented:
- `coord_proj` : Like `coord_map` only better `:-)` - `coord_proj` : Like `coord_map` only better 😜
- `geom_xspline` : Connect control points/observations with an X-spline - `geom_xspline` : Connect control points/observations with an X-spline
- `stat_xspline` : Connect control points/observations with an X-spline - `stat_xspline` : Connect control points/observations with an X-spline
- `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
@ -38,6 +36,7 @@ The following functions are implemented:
### News ### News
- Version 0.1.0.9000 released - Tweaks for ggplot2 2.0 release
- Version 0.0.4.9000 released - `stat_ash` - Version 0.0.4.9000 released - `stat_ash`
- Version 0.0.3.9000 released - `coord_proj`! (requires my github copy of ggplot2 for now) - Version 0.0.3.9000 released - `coord_proj`! (requires my github copy of ggplot2 for now)
- Version 0.0.2.9005 released - cleanup before blog post - Version 0.0.2.9005 released - cleanup before blog post
@ -48,7 +47,7 @@ The following functions are implemented:
```{r eval=FALSE} ```{r eval=FALSE}
# you'll want to see the vignettes, trust me # you'll want to see the vignettes, trust me
devtools::install_github("hadley/ggplot2", build_vignettes=TRUE) install.packages("ggplot2")
devtools::install_github("hrbrmstr/ggalt") devtools::install_github("hrbrmstr/ggalt")
``` ```
@ -139,7 +138,7 @@ set.seed(1492)
dat <- data.frame(cond = factor(rep(c("A","B"), each=200)), dat <- data.frame(cond = factor(rep(c("A","B"), each=200)),
rating = c(rnorm(200),rnorm(200, mean=.8))) rating = c(rnorm(200),rnorm(200, mean=.8)))
ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(alpha=0) ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(fill="#00000000")
ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3) ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3)
@ -154,9 +153,9 @@ grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
cols <- RColorBrewer::brewer.pal(3, "Dark2") cols <- RColorBrewer::brewer.pal(3, "Dark2")
ggplot(dat, aes(x)) + ggplot(dat, aes(x)) +
stat_ash(alpha=1/2, fill=cols[3]) + stat_ash(alpha=1/3, fill=cols[3]) +
stat_bkde(alpha=1/2, fill=cols[2]) + stat_bkde(alpha=1/3, fill=cols[2]) +
stat_density(alpha=1/2, fill=cols[1]) + stat_density(alpha=1/3, fill=cols[1]) +
geom_rug() + geom_rug() +
labs(x=NULL, y="density/estimate") + labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) + scale_x_continuous(expand=c(0,0)) +
@ -168,15 +167,15 @@ ggplot(dat, aes(x)) +
### Alternate 2D density plots ### Alternate 2D density plots
```{r bkde2d} ```{r bkde2d}
geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting) m <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
geom_point() +
xlim(0.5, 6) +
ylim(40, 110)
ggplot(geyser_dat, aes(x, y)) + m + geom_bkde2d(bandwidth=c(0.5, 4))
geom_point() +
geom_bkde2d(bandwidth=c(0.7, 7)) m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7))
``` ```
### `coord_proj` LIVES! (still needs work) ### `coord_proj` LIVES! (still needs work)
@ -193,17 +192,6 @@ gg <- gg + coord_proj("+proj=wintri")
gg gg
``` ```
### Test Results
```{r}
library(ggalt)
library(testthat)
date()
test_dir("tests/")
```
### Code of Conduct ### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).

284
README.html

File diff suppressed because one or more lines are too long

129
README.md

@ -1,51 +1,56 @@
<!-- README.md is generated from README.Rmd. Please edit that file --> <!-- README.md is generated from README.Rmd. Please edit that file -->
`ggalt` : Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2'
A package containing additional/alternate 'geoms', 'coords' and 'stats' for use with the revamped (late 2015) version of ggplot2.
The first three forays into this brave, new `ggplot2` world are *splines*! and being able to use the (much better) `KernSmooth::bkde` and `KernSmooth::bkde2D` for density plots and an initial port of the (still needing work) `coord_proj`.
**NOTE** `ggalt` : Alternate/Extra 'Geoms', 'Stats' and 'Coords' for 'ggplot2'
Until the new `ggplot2` version is on CRAN, you'll need to install it from github via `devtools::install_github("hrbrmstr/ggplot2")`. Locally, I have goth `ggalt` and my `ggplot2` in a "develment mode" install via `devtools::dev_mode()`. Since the new `ggplot2` breaks *many* other packages (like `plotly`, CRAN `ggthemes`, `ggmap` and more), keeping it squirreled away in it's own area is a good idea until everyone catches up. A package containing additional/alternate 'geoms', 'coords' and 'stats' for use with ggplot2 2.0+.
The first three forays into this brave, new `ggplot2` world are _splines_! and being able to use the (much better) `KernSmooth::bkde` and `KernSmooth::bkde2D` for density plots and an initial port of the (still needing work) `coord_proj`.
The following functions are implemented: The following functions are implemented:
- `coord_proj` : Like `coord_map` only better `:-)` - `coord_proj` : Like `coord_map` only better 😜
- `geom_xspline` : Connect control points/observations with an X-spline - `geom_xspline` : Connect control points/observations with an X-spline
- `stat_xspline` : Connect control points/observations with an X-spline - `stat_xspline` : Connect control points/observations with an X-spline
- `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
- `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
- `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_ash` : Compute and display a univariate averaged shifted histogram (polynomial kernel) (uses `ash::ash1`/`ash::bin1`) - `stat_ash` : Compute and display a univariate averaged shifted histogram (polynomial kernel) (uses `ash::ash1`/`ash::bin1`)
### News ### News
- Version 0.0.4.9000 released - `stat_ash` - Version 0.1.0.9000 released - Tweaks for ggplot2 2.0 release
- Version 0.0.3.9000 released - `coord_proj`! (requires my github copy of ggplot2 for now) - Version 0.0.4.9000 released - `stat_ash`
- Version 0.0.2.9005 released - cleanup before blog post - Version 0.0.3.9000 released - `coord_proj`! (requires my github copy of ggplot2 for now)
- Version 0.0.2.9002 released - working 2D density plots - Version 0.0.2.9005 released - cleanup before blog post
- Version 0.0.2.9000 released - Version 0.0.2.9002 released - working 2D density plots
- Version 0.0.2.9000 released
### Installation ### Installation
``` r
```r
# you'll want to see the vignettes, trust me # you'll want to see the vignettes, trust me
devtools::install_github("hadley/ggplot2", build_vignettes=TRUE) install.packages("ggplot2")
devtools::install_github("hrbrmstr/ggalt") devtools::install_github("hrbrmstr/ggalt")
``` ```
### Usage ### Usage
``` r
```r
library(ggplot2) library(ggplot2)
library(gridExtra) library(gridExtra)
library(ggalt) library(ggalt)
# current verison # current verison
packageVersion("ggalt") packageVersion("ggalt")
#> [1] '0.0.4.9000' #> [1] '0.1.0.9000'
set.seed(1492) set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10), dat <- data.frame(x=c(1:10, 1:10, 1:10),
@ -56,7 +61,8 @@ dat <- data.frame(x=c(1:10, 1:10, 1:10),
### Splines! ### Splines!
``` r
```r
ggplot(dat, aes(x, y, group=group, color=group)) + ggplot(dat, aes(x, y, group=group, color=group)) +
geom_point() + geom_point() +
geom_line() geom_line()
@ -64,7 +70,7 @@ ggplot(dat, aes(x, y, group=group, color=group)) +
<img src="README_figs/README-splines-1.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-1.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point() + geom_point() +
@ -74,7 +80,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-2.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-2.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -84,7 +90,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-3.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-3.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -94,7 +100,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-4.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-4.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -104,7 +110,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-5.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-5.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -114,7 +120,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-6.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-6.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -124,7 +130,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
<img src="README_figs/README-splines-7.png" title="" alt="" width="672" /> <img src="README_figs/README-splines-7.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x, y, group=group, color=factor(group))) + ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") + geom_point(color="black") +
@ -136,7 +142,8 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
#### Alternate (better) density plots #### Alternate (better) density plots
``` r
```r
# bkde # bkde
data(geyser, package="MASS") data(geyser, package="MASS")
@ -148,7 +155,7 @@ ggplot(geyser, aes(x=duration)) +
<img src="README_figs/README-bkde_ash-1.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-1.png" title="" alt="" width="672" />
``` r ```r
ggplot(geyser, aes(x=duration)) + ggplot(geyser, aes(x=duration)) +
geom_bkde(alpha=1/2) geom_bkde(alpha=1/2)
@ -157,7 +164,7 @@ ggplot(geyser, aes(x=duration)) +
<img src="README_figs/README-bkde_ash-2.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-2.png" title="" alt="" width="672" />
``` r ```r
ggplot(geyser, aes(x=duration)) + ggplot(geyser, aes(x=duration)) +
stat_bkde(bandwidth=0.25) stat_bkde(bandwidth=0.25)
@ -165,7 +172,7 @@ ggplot(geyser, aes(x=duration)) +
<img src="README_figs/README-bkde_ash-3.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-3.png" title="" alt="" width="672" />
``` r ```r
ggplot(geyser, aes(x=duration)) + ggplot(geyser, aes(x=duration)) +
geom_bkde(bandwidth=0.25) geom_bkde(bandwidth=0.25)
@ -173,20 +180,20 @@ ggplot(geyser, aes(x=duration)) +
<img src="README_figs/README-bkde_ash-4.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-4.png" title="" alt="" width="672" />
``` r ```r
set.seed(1492) set.seed(1492)
dat <- data.frame(cond = factor(rep(c("A","B"), each=200)), dat <- data.frame(cond = factor(rep(c("A","B"), each=200)),
rating = c(rnorm(200),rnorm(200, mean=.8))) rating = c(rnorm(200),rnorm(200, mean=.8)))
ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(alpha=0) ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(fill="#00000000")
#> Bandwidth not specified. Using '0.36', via KernSmooth::dpik. #> Bandwidth not specified. Using '0.36', via KernSmooth::dpik.
#> Bandwidth not specified. Using '0.31', via KernSmooth::dpik. #> Bandwidth not specified. Using '0.31', via KernSmooth::dpik.
``` ```
<img src="README_figs/README-bkde_ash-5.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-5.png" title="" alt="" width="672" />
``` r ```r
ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3) ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3)
#> Bandwidth not specified. Using '0.36', via KernSmooth::dpik. #> Bandwidth not specified. Using '0.36', via KernSmooth::dpik.
@ -195,7 +202,7 @@ ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3)
<img src="README_figs/README-bkde_ash-6.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-6.png" title="" alt="" width="672" />
``` r ```r
# ash # ash
@ -211,13 +218,13 @@ grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
<img src="README_figs/README-bkde_ash-7.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde_ash-7.png" title="" alt="" width="672" />
``` r ```r
cols <- RColorBrewer::brewer.pal(3, "Dark2") cols <- RColorBrewer::brewer.pal(3, "Dark2")
ggplot(dat, aes(x)) + ggplot(dat, aes(x)) +
stat_ash(alpha=1/2, fill=cols[3]) + stat_ash(alpha=1/3, fill=cols[3]) +
stat_bkde(alpha=1/2, fill=cols[2]) + stat_bkde(alpha=1/3, fill=cols[2]) +
stat_density(alpha=1/2, fill=cols[1]) + stat_density(alpha=1/3, fill=cols[1]) +
geom_rug() + geom_rug() +
labs(x=NULL, y="density/estimate") + labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) + scale_x_continuous(expand=c(0,0)) +
@ -232,28 +239,29 @@ ggplot(dat, aes(x)) +
### Alternate 2D density plots ### Alternate 2D density plots
``` r
geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) + ```r
geom_point() + m <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
geom_bkde2d(bandwidth=c(0.7, 7)) geom_point() +
xlim(0.5, 6) +
ylim(40, 110)
m + geom_bkde2d(bandwidth=c(0.5, 4))
``` ```
<img src="README_figs/README-bkde2d-1.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde2d-1.png" title="" alt="" width="672" />
``` r ```r
ggplot(geyser_dat, aes(x, y)) + m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7))
``` ```
<img src="README_figs/README-bkde2d-2.png" title="" alt="" width="672" /> <img src="README_figs/README-bkde2d-2.png" title="" alt="" width="672" />
### `coord_proj` LIVES! (still needs work) ### `coord_proj` LIVES! (still needs work)
``` r
```r
# devtools::install_github("hrbrmstr/ggplot2") # devtools::install_github("hrbrmstr/ggplot2")
world <- map_data("world") world <- map_data("world")
#> #>
@ -271,20 +279,7 @@ gg
<img src="README_figs/README-coord_proj-1.png" title="" alt="" width="672" /> <img src="README_figs/README-coord_proj-1.png" title="" alt="" width="672" />
### Test Results
``` r
library(ggalt)
library(testthat)
date()
#> [1] "Sat Oct 31 10:07:15 2015"
test_dir("tests/")
#> testthat results ========================================================================================================
#> OK: 0 SKIPPED: 0 FAILED: 0
```
### Code of Conduct ### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.

BIN
README_figs/README-bkde2d-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 236 KiB

BIN
README_figs/README-bkde2d-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 112 KiB

BIN
README_figs/README-bkde_ash-8.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 86 KiB

11
man/coord_proj.Rd

@ -4,13 +4,12 @@
\alias{coord_proj} \alias{coord_proj}
\title{Like \code{coord_map} only better :-)} \title{Like \code{coord_map} only better :-)}
\usage{ \usage{
coord_proj(proj = NULL, inverse = FALSE, degrees = TRUE,
coord_proj(proj = "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs", ellps.default = "sphere", xlim = NULL, ylim = NULL)
inverse = FALSE, degrees = TRUE, ellps.default = "sphere",
xlim = NULL, ylim = NULL)
} }
\arguments{ \arguments{
\item{proj}{projection definition} \item{proj}{projection definition. If left \code{NULL} will default to
a Robinson projection}
\item{inverse}{if \code{TRUE} inverse projection is performed (from a \item{inverse}{if \code{TRUE} inverse projection is performed (from a
cartographic projection into lat/long), otherwise projects from cartographic projection into lat/long), otherwise projects from
@ -33,7 +32,7 @@ directly).}
\description{ \description{
The representation of a portion of the earth, which is approximately The representation of a portion of the earth, which is approximately
spherical, onto a flat 2D plane requires a projection. This is what spherical, onto a flat 2D plane requires a projection. This is what
\code{coord_proj} does, using the \link[proj4]{project()} function from \code{coord_proj} does, using the \code{proj4::project()} function from
the \code{proj4} package. the \code{proj4} package.
} }

10
man/geom_bkde2d.Rd

@ -72,13 +72,15 @@ the default plot specification, e.g. \code{\link{borders}}.}
\item Other arguments passed on to the stat. \item Other arguments passed on to the stat.
}} }}
\item{truncate}{logical flag: if TRUE, data with x values outside the range \item{geom}{default geom to use with this stat}
specified by range.x are ignored. see \code{\link[KernSmooth]{bkde2D}}
for details}
\item{gridsize}{vector containing the number of equally spaced points in each \item{grid_size}{vector containing the number of equally spaced points in each
direction over which the density is to be estimated. see direction over which the density is to be estimated. see
\code{\link[KernSmooth]{bkde2D}} for details} \code{\link[KernSmooth]{bkde2D}} for details}
\item{truncate}{logical flag: if TRUE, data with x values outside the range
specified by range.x are ignored. see \code{\link[KernSmooth]{bkde2D}}
for details}
} }
\description{ \description{
Contours from a 2d density estimate. Contours from a 2d density estimate.

19
man/ggalt-ggproto.Rd

@ -1,16 +1,27 @@
% Generated by roxygen2: 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 % Please edit documentation in R/coord_proj.r, R/geom_ash.r, R/geom_bkde.r, R/geom_bkde2d.r, R/geom_xspline.r
\docType{data} \docType{data}
\name{GeomBkde} \name{CoordProj}
\alias{CoordProj}
\alias{GeomBkde} \alias{GeomBkde}
\alias{GeomBkde2d} \alias{GeomBkde2d}
\alias{GeomXspline} \alias{GeomXspline}
\alias{StatAsh}
\alias{StatBkde} \alias{StatBkde}
\alias{StatBkde2d} \alias{StatBkde2d}
\alias{StatXspline} \alias{StatXspline}
\title{GeomXspline} \title{Geom Proto}
\description{ \description{
GeomXspline Geom Proto
Geom Proto
Geom Proto
Geom Proto
Geom Proto
} }
\keyword{datasets} \keyword{datasets}
\keyword{internal}

3
man/ggalt.Rd

@ -6,8 +6,7 @@
\alias{ggalt-package} \alias{ggalt-package}
\title{Extra Geoms, Stats and Coords for 'ggplot2'} \title{Extra Geoms, Stats and Coords for 'ggplot2'}
\description{ \description{
A package containing additional geoms, coords and stats for the revamped A package containing additional geoms, coords and stats for the ggplot2 2.0+
(late 2015) version of ggplot2.
} }
\author{ \author{
Bob Rudis (@hrbrmstr) Bob Rudis (@hrbrmstr)

Loading…
Cancel
Save