Browse Source

finished 2D

tags/v0.1.1
hrbrmstr 9 years ago
parent
commit
93120484ad
  1. 2
      DESCRIPTION
  2. 10
      R/geom_bkde2d.r
  3. 16
      README.Rmd
  4. 17
      README.md
  5. BIN
      README_figs/README-unnamed-chunk-4-11.png
  6. BIN
      README_figs/README-unnamed-chunk-4-12.png

2
DESCRIPTION

@ -1,6 +1,6 @@
Package: ggalt
Title: Extra Geoms, Stats and Coords for 'ggplot2'
Version: 0.0.2.9000
Version: 0.0.2.9002
Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")))
Description: A package contains additional geoms, coords and stats for the revamped (late 2015) version of ggplot2.
Depends: R (>= 3.0.0), ggplot2 (>= 1.0.1.9003)

10
R/geom_bkde2d.r

@ -81,7 +81,15 @@ StatBkde2d <- ggproto("StatBkde2d", Stat,
compute_group = function(data, scales, contour=TRUE, bandwidth, grid_size=c(51, 51), range.x=NULL,
truncate=TRUE) {
if (is.null(range.x)) range.x <- list(range(data$x), range(data$y))
if (is.null(range.x)) {
x_range <- range(data$x)
y_range <- range(data$y)
x_range[1] <- x_range[1] - 1.5 * bandwidth[1]
x_range[2] <- x_range[2] + 1.5 * bandwidth[1]
y_range[1] <- y_range[1] - 1.5 * bandwidth[2]
y_range[2] <- y_range[2] + 1.5 * bandwidth[2]
range.x <- list(x_range, y_range)
}
dens <- KernSmooth::bkde2D(
as.matrix(data.frame(x=data$x, y=data$y)),

16
README.Rmd

@ -20,9 +20,7 @@ knitr::opts_chunk$set(
A package containing additional geoms, coords and stats for the revamped (late 2015) version
of ggplot2.
The first two forays into this brave, new `ggplot2` world are _splines_! and being able to
use the (much better) `KernSmooth::bkde` for density plots. Support for `KernSmooth::bkde2D` is
a WIP.
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.
*NOTE*
@ -34,11 +32,12 @@ The following functions are implemented:
- `stat_xspline` : Connect control points/observations with an X-spline
- `geom_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`) **WIP**
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) **WIP**
- `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
### News
- Version 0.0.2.9002 released - working 2D density plots
- Version 0.0.2.9000 released
### Installation
@ -122,14 +121,11 @@ geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
geom_bkde2d(bandwidth=c(0.7, 7)) +
xlim(0, 6) + ylim(35, 120)
geom_bkde2d(bandwidth=c(0.7, 7))
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7)) +
xlim(0, 6) + ylim(35, 120)
stat_bkde2d(bandwidth=c(0.7, 7))
```
### Test Results

17
README.md

@ -3,7 +3,7 @@
A package containing additional geoms, coords and stats for the revamped (late 2015) version of ggplot2.
The first two forays into this brave, new `ggplot2` world are *splines*! and being able to use the (much better) `KernSmooth::bkde` for density plots. Support for `KernSmooth::bkde2D` is a WIP.
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.
*NOTE*
@ -15,11 +15,12 @@ The following functions are implemented:
- `stat_xspline` : Connect control points/observations with an X-spline
- `geom_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`) **WIP**
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) **WIP**
- `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
- `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`)
### News
- Version 0.0.2.9002 released - working 2D density plots
- Version 0.0.2.9000 released
### Installation
@ -38,7 +39,7 @@ library(ggalt)
# current verison
packageVersion("ggalt")
#> [1] '0.0.2.9000'
#> [1] '0.0.2.9002'
set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10),
@ -151,8 +152,7 @@ geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
geom_bkde2d(bandwidth=c(0.7, 7)) +
xlim(0, 6) + ylim(35, 120)
geom_bkde2d(bandwidth=c(0.7, 7))
```
<img src="README_figs/README-unnamed-chunk-4-11.png" title="" alt="" width="672" />
@ -161,8 +161,7 @@ ggplot(geyser_dat, aes(x, y)) +
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7)) +
xlim(0, 6) + ylim(35, 120)
stat_bkde2d(bandwidth=c(0.7, 7))
```
<img src="README_figs/README-unnamed-chunk-4-12.png" title="" alt="" width="672" />
@ -174,7 +173,7 @@ library(ggalt)
library(testthat)
date()
#> [1] "Tue Sep 8 18:56:26 2015"
#> [1] "Tue Sep 8 21:13:04 2015"
test_dir("tests/")
#> testthat results ========================================================================================================

BIN
README_figs/README-unnamed-chunk-4-11.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 272 KiB

BIN
README_figs/README-unnamed-chunk-4-12.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 272 KiB

Loading…
Cancel
Save