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. 63
      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$
^README\.md$
^README_figs
^README\.html$

9
DESCRIPTION

@ -1,6 +1,6 @@
Package: ggalt
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")))
Description: A package containing additional/alternate 'geoms', 'coords' and
'stats' for use with the revamped (late 2015) version of ggplot2.
@ -13,14 +13,17 @@ Suggests:
testthat,
gridExtra
Encoding: UTF-8
Enhances: ggplot2
Imports:
graphics,
grDevices,
dplyr,
RColorBrewer,
KernSmooth,
proj4,
scales,
grid,
gtable,
ash
RoxygenNote: 5.0.0
ash,
MASS
RoxygenNote: 5.0.1

1
NAMESPACE

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

19
R/coord_proj.r

@ -2,10 +2,11 @@
#'
#' The representation of a portion of the earth, which is approximately
#' 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.
#'
#' @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
#' cartographic projection into lat/long), otherwise projects from
#' lat/long into a cartographic projection.
@ -20,10 +21,15 @@
#' @param xlim manually specific x limits (in degrees of longitude)
#' @param ylim manually specific y limits (in degrees of latitude)
#' @export
coord_proj <- function(proj="+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
inverse = FALSE, degrees = TRUE,
coord_proj <- function(proj=NULL, inverse = FALSE, degrees = TRUE,
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,
proj = proj,
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
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
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
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export
GeomBkde <- ggproto("GeomBkde", GeomArea,
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
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export
GeomBkde2d <- ggproto("GeomBkde2d", GeomPath,
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},
#' it will be computed for you but will most likely not yield optimal
#' 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
#' \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
#' minimum and maximum values of x at which to compute the estimate for
#' 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
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export
GeomXspline <- ggproto("GeomXspline", GeomLine,
required_aes = c("x", "y"),
default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = NA)
)
#' @export

4
R/ggalt-package.r

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

46
README.Rmd

@ -1,5 +1,7 @@
---
output:
html_document:
keep_md: true
md_document:
variant: markdown_github
---
@ -17,17 +19,13 @@ fig.retina = 2,
`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`.
**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:
- `coord_proj` : Like `coord_map` only better `:-)`
- `coord_proj` : Like `coord_map` only better 😜
- `geom_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`)
@ -38,6 +36,7 @@ The following functions are implemented:
### News
- Version 0.1.0.9000 released - Tweaks for ggplot2 2.0 release
- 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.2.9005 released - cleanup before blog post
@ -48,7 +47,7 @@ The following functions are implemented:
```{r eval=FALSE}
# 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")
```
@ -139,7 +138,7 @@ set.seed(1492)
dat <- data.frame(cond = factor(rep(c("A","B"), each=200)),
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)
@ -154,9 +153,9 @@ grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
cols <- RColorBrewer::brewer.pal(3, "Dark2")
ggplot(dat, aes(x)) +
stat_ash(alpha=1/2, fill=cols[3]) +
stat_bkde(alpha=1/2, fill=cols[2]) +
stat_density(alpha=1/2, fill=cols[1]) +
stat_ash(alpha=1/3, fill=cols[3]) +
stat_bkde(alpha=1/3, fill=cols[2]) +
stat_density(alpha=1/3, fill=cols[1]) +
geom_rug() +
labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) +
@ -168,15 +167,15 @@ ggplot(dat, aes(x)) +
### Alternate 2D density plots
```{r bkde2d}
geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) +
m <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
geom_point() +
geom_bkde2d(bandwidth=c(0.7, 7))
xlim(0.5, 6) +
ylim(40, 110)
m + geom_bkde2d(bandwidth=c(0.5, 4))
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)
@ -193,17 +192,6 @@ gg <- gg + coord_proj("+proj=wintri")
gg
```
### Test Results
```{r}
library(ggalt)
library(testthat)
date()
test_dir("tests/")
```
### Code of Conduct
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

63
README.md

@ -1,17 +1,17 @@
<!-- 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'
A package containing additional/alternate 'geoms', 'coords' and 'stats' for use with ggplot2 2.0+.
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 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:
- `coord_proj` : Like `coord_map` only better `:-)`
- `coord_proj` : Like `coord_map` only better 😜
- `geom_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`)
@ -22,6 +22,7 @@ The following functions are implemented:
### News
- Version 0.1.0.9000 released - Tweaks for ggplot2 2.0 release
- 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.2.9005 released - cleanup before blog post
@ -30,14 +31,18 @@ The following functions are implemented:
### Installation
```r
# 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")
```
### Usage
```r
library(ggplot2)
library(gridExtra)
@ -45,7 +50,7 @@ library(ggalt)
# current verison
packageVersion("ggalt")
#> [1] '0.0.4.9000'
#> [1] '0.1.0.9000'
set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10),
@ -56,6 +61,7 @@ dat <- data.frame(x=c(1:10, 1:10, 1:10),
### Splines!
```r
ggplot(dat, aes(x, y, group=group, color=group)) +
geom_point() +
@ -136,6 +142,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
#### Alternate (better) density plots
```r
# bkde
@ -179,7 +186,7 @@ set.seed(1492)
dat <- data.frame(cond = factor(rep(c("A","B"), each=200)),
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.31', via KernSmooth::dpik.
```
@ -215,9 +222,9 @@ grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
cols <- RColorBrewer::brewer.pal(3, "Dark2")
ggplot(dat, aes(x)) +
stat_ash(alpha=1/2, fill=cols[3]) +
stat_bkde(alpha=1/2, fill=cols[2]) +
stat_density(alpha=1/2, fill=cols[1]) +
stat_ash(alpha=1/3, fill=cols[3]) +
stat_bkde(alpha=1/3, fill=cols[2]) +
stat_density(alpha=1/3, fill=cols[1]) +
geom_rug() +
labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) +
@ -232,27 +239,28 @@ ggplot(dat, aes(x)) +
### Alternate 2D density plots
``` r
geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) +
```r
m <- ggplot(faithful, aes(x = eruptions, y = waiting)) +
geom_point() +
geom_bkde2d(bandwidth=c(0.7, 7))
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" />
```r
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7))
m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
```
<img src="README_figs/README-bkde2d-2.png" title="" alt="" width="672" />
### `coord_proj` LIVES! (still needs work)
```r
# devtools::install_github("hrbrmstr/ggplot2")
world <- map_data("world")
@ -271,20 +279,7 @@ gg
<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
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}
\title{Like \code{coord_map} only better :-)}
\usage{
coord_proj(proj = "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs",
inverse = FALSE, degrees = TRUE, ellps.default = "sphere",
xlim = NULL, ylim = NULL)
coord_proj(proj = NULL, inverse = FALSE, degrees = TRUE,
ellps.default = "sphere", xlim = NULL, ylim = NULL)
}
\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
cartographic projection into lat/long), otherwise projects from
@ -33,7 +32,7 @@ directly).}
\description{
The representation of a portion of the earth, which is approximately
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.
}

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{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}
\item{geom}{default geom to use with this stat}
\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
\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{
Contours from a 2d density estimate.

19
man/ggalt-ggproto.Rd

@ -1,16 +1,27 @@
% 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}
\name{GeomBkde}
\name{CoordProj}
\alias{CoordProj}
\alias{GeomBkde}
\alias{GeomBkde2d}
\alias{GeomXspline}
\alias{StatAsh}
\alias{StatBkde}
\alias{StatBkde2d}
\alias{StatXspline}
\title{GeomXspline}
\title{Geom Proto}
\description{
GeomXspline
Geom Proto
Geom Proto
Geom Proto
Geom Proto
Geom Proto
}
\keyword{datasets}
\keyword{internal}

3
man/ggalt.Rd

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

Loading…
Cancel
Save