Browse Source

reorg README

tags/v0.1.1
hrbrmstr 9 years ago
parent
commit
033e3ec610
  1. 59
      README.Rmd
  2. 120
      README.md
  3. 0
      README_figs/README-bkde2d-1.png
  4. 0
      README_figs/README-bkde2d-2.png
  5. 0
      README_figs/README-bkde_ash-1.png
  6. 0
      README_figs/README-bkde_ash-2.png
  7. 0
      README_figs/README-bkde_ash-3.png
  8. 0
      README_figs/README-bkde_ash-4.png
  9. 0
      README_figs/README-bkde_ash-5.png
  10. 0
      README_figs/README-bkde_ash-6.png
  11. 0
      README_figs/README-bkde_ash-7.png
  12. 0
      README_figs/README-bkde_ash-8.png
  13. 0
      README_figs/README-coord_proj-1.png
  14. 0
      README_figs/README-splines-1.png
  15. 0
      README_figs/README-splines-2.png
  16. 0
      README_figs/README-splines-3.png
  17. 0
      README_figs/README-splines-4.png
  18. 0
      README_figs/README-splines-5.png
  19. 0
      README_figs/README-splines-6.png
  20. 0
      README_figs/README-splines-7.png
  21. 0
      README_figs/README-splines-8.png

59
README.Rmd

@ -71,7 +71,11 @@ dat <- data.frame(x=c(1:10, 1:10, 1:10),
y=c(sample(15:30, 10), 2*sample(15:30, 10), 3*sample(15:30, 10)),
group=factor(c(rep(1, 10), rep(2, 10), rep(3, 10)))
)
```
### Splines!
```{r splines}
ggplot(dat, aes(x, y, group=group, color=group)) +
geom_point() +
geom_line()
@ -110,8 +114,12 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_point(color="black") +
geom_smooth(se=FALSE, linetype="dashed", size=0.5) +
geom_xspline(spline_shape=-1, size=0.5)
```
# Better density plots
#### Alternate (better) density plots
```{r bkde_ash}
# bkde
data(geyser, package="MASS")
@ -135,9 +143,31 @@ ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(alpha=0)
ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3)
# ash
set.seed(1492)
dat <- data.frame(x=rnorm(100))
grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
ggplot(dat, aes(x)) + stat_bkde(),
ggplot(dat, aes(x)) + stat_density(),
nrow=3)
# 2D KernSmooth::bkde2D plots are a WIP
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]) +
geom_rug() +
labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) +
theme_bw() +
theme(panel.grid=element_blank()) +
theme(panel.border=element_blank())
```
### Alternate 2D density plots
```{r bkde2d}
geyser_dat <- data.frame(x=geyser$duration, y=geyser$waiting)
ggplot(geyser_dat, aes(x, y)) +
@ -147,9 +177,11 @@ ggplot(geyser_dat, aes(x, y)) +
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)
```{r coord_proj}
world <- map_data("world")
world <- world[world$region != "Antarctica",]
@ -158,27 +190,6 @@ gg <- gg + geom_map(data=world, map=world,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri")
gg
# stat_ash + compare density plots
set.seed(1492)
dat <- data.frame(x=rnorm(100))
grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
ggplot(dat, aes(x)) + stat_bkde(),
ggplot(dat, aes(x)) + stat_density(),
nrow=3)
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]) +
geom_rug() +
labs(x=NULL, y="density/estimate") +
scale_x_continuous(expand=c(0,0)) +
theme_bw() +
theme(panel.grid=element_blank()) +
theme(panel.border=element_blank())
```
### Test Results

120
README.md

@ -52,13 +52,17 @@ dat <- data.frame(x=c(1:10, 1:10, 1:10),
y=c(sample(15:30, 10), 2*sample(15:30, 10), 3*sample(15:30, 10)),
group=factor(c(rep(1, 10), rep(2, 10), rep(3, 10)))
)
```
### Splines!
``` r
ggplot(dat, aes(x, y, group=group, color=group)) +
geom_point() +
geom_line()
```
<img src="README_figs/README-unnamed-chunk-4-1.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-1.png" title="" alt="" width="672" />
``` r
@ -68,7 +72,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_smooth(se=FALSE, linetype="dashed", size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-2.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-2.png" title="" alt="" width="672" />
``` r
@ -78,7 +82,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-3.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-3.png" title="" alt="" width="672" />
``` r
@ -88,7 +92,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(spline_shape=-0.4, size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-4.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-4.png" title="" alt="" width="672" />
``` r
@ -98,7 +102,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(spline_shape=0.4, size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-5.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-5.png" title="" alt="" width="672" />
``` r
@ -108,7 +112,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(spline_shape=1, size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-6.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-6.png" title="" alt="" width="672" />
``` r
@ -118,7 +122,7 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(spline_shape=0, size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-7.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-7.png" title="" alt="" width="672" />
``` r
@ -128,11 +132,12 @@ ggplot(dat, aes(x, y, group=group, color=factor(group))) +
geom_xspline(spline_shape=-1, size=0.5)
```
<img src="README_figs/README-unnamed-chunk-4-8.png" title="" alt="" width="672" />
<img src="README_figs/README-splines-8.png" title="" alt="" width="672" />
``` r
#### Alternate (better) density plots
# Better density plots
``` r
# bkde
data(geyser, package="MASS")
@ -141,7 +146,7 @@ ggplot(geyser, aes(x=duration)) +
#> Bandwidth not specified. Using '0.14', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-9.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-1.png" title="" alt="" width="672" />
``` r
@ -150,7 +155,7 @@ ggplot(geyser, aes(x=duration)) +
#> Bandwidth not specified. Using '0.14', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-10.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-2.png" title="" alt="" width="672" />
``` r
@ -158,7 +163,7 @@ ggplot(geyser, aes(x=duration)) +
stat_bkde(bandwidth=0.25)
```
<img src="README_figs/README-unnamed-chunk-4-11.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-3.png" title="" alt="" width="672" />
``` r
@ -166,7 +171,7 @@ ggplot(geyser, aes(x=duration)) +
geom_bkde(bandwidth=0.25)
```
<img src="README_figs/README-unnamed-chunk-4-12.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-4.png" title="" alt="" width="672" />
``` r
@ -179,7 +184,7 @@ ggplot(dat, aes(x=rating, color=cond)) + geom_bkde(alpha=0)
#> Bandwidth not specified. Using '0.31', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-13.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-5.png" title="" alt="" width="672" />
``` r
@ -188,50 +193,11 @@ ggplot(dat, aes(x=rating, fill=cond)) + geom_bkde(alpha=0.3)
#> Bandwidth not specified. Using '0.31', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-14.png" title="" alt="" width="672" />
``` r
# 2D KernSmooth::bkde2D plots are a WIP
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))
```
<img src="README_figs/README-unnamed-chunk-4-15.png" title="" alt="" width="672" />
``` r
ggplot(geyser_dat, aes(x, y)) +
geom_point() +
stat_bkde2d(bandwidth=c(0.7, 7))
```
<img src="README_figs/README-unnamed-chunk-4-16.png" title="" alt="" width="672" />
``` r
# coord_proj LIVES! (still needs work)
world <- map_data("world")
world <- world[world$region != "Antarctica",]
gg <- ggplot()
gg <- gg + geom_map(data=world, map=world,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri")
gg
```
<img src="README_figs/README-unnamed-chunk-4-17.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-6.png" title="" alt="" width="672" />
``` r
# stat_ash + compare density plots
# ash
set.seed(1492)
dat <- data.frame(x=rnorm(100))
@ -243,7 +209,7 @@ grid.arrange(ggplot(dat, aes(x)) + stat_ash(),
#> Bandwidth not specified. Using '0.43', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-18.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-7.png" title="" alt="" width="672" />
``` r
@ -262,7 +228,43 @@ ggplot(dat, aes(x)) +
#> Bandwidth not specified. Using '0.43', via KernSmooth::dpik.
```
<img src="README_figs/README-unnamed-chunk-4-19.png" title="" alt="" width="672" />
<img src="README_figs/README-bkde_ash-8.png" title="" alt="" width="672" />
### Alternate 2D density plots
``` r
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))
```
<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))
```
<img src="README_figs/README-bkde2d-2.png" title="" alt="" width="672" />
### `coord_proj` LIVES! (still needs work)
``` r
world <- map_data("world")
world <- world[world$region != "Antarctica",]
gg <- ggplot()
gg <- gg + geom_map(data=world, map=world,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri")
gg
```
<img src="README_figs/README-coord_proj-1.png" title="" alt="" width="672" />
### Test Results
@ -271,7 +273,7 @@ library(ggalt)
library(testthat)
date()
#> [1] "Sun Sep 13 07:22:24 2015"
#> [1] "Sun Sep 13 07:27:26 2015"
test_dir("tests/")
#> testthat results ========================================================================================================

0
README_figs/README-unnamed-chunk-4-16.png → README_figs/README-bkde2d-1.png

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 272 KiB

0
README_figs/README-unnamed-chunk-4-15.png → README_figs/README-bkde2d-2.png

Before

Width:  |  Height:  |  Size: 272 KiB

After

Width:  |  Height:  |  Size: 272 KiB

0
README_figs/README-unnamed-chunk-4-9.png → README_figs/README-bkde_ash-1.png

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

0
README_figs/README-unnamed-chunk-4-10.png → README_figs/README-bkde_ash-2.png

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

0
README_figs/README-unnamed-chunk-4-12.png → README_figs/README-bkde_ash-3.png

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

0
README_figs/README-unnamed-chunk-4-11.png → README_figs/README-bkde_ash-4.png

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

0
README_figs/README-unnamed-chunk-4-13.png → README_figs/README-bkde_ash-5.png

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

0
README_figs/README-unnamed-chunk-4-14.png → README_figs/README-bkde_ash-6.png

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 72 KiB

0
README_figs/README-unnamed-chunk-4-18.png → README_figs/README-bkde_ash-7.png

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

0
README_figs/README-unnamed-chunk-4-19.png → README_figs/README-bkde_ash-8.png

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 87 KiB

0
README_figs/README-unnamed-chunk-4-17.png → README_figs/README-coord_proj-1.png

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

0
README_figs/README-unnamed-chunk-4-1.png → README_figs/README-splines-1.png

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

0
README_figs/README-unnamed-chunk-4-2.png → README_figs/README-splines-2.png

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

0
README_figs/README-unnamed-chunk-4-3.png → README_figs/README-splines-3.png

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

0
README_figs/README-unnamed-chunk-4-4.png → README_figs/README-splines-4.png

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

0
README_figs/README-unnamed-chunk-4-5.png → README_figs/README-splines-5.png

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

0
README_figs/README-unnamed-chunk-4-6.png → README_figs/README-splines-6.png

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

0
README_figs/README-unnamed-chunk-4-7.png → README_figs/README-splines-7.png

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 137 KiB

0
README_figs/README-unnamed-chunk-4-8.png → README_figs/README-splines-8.png

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Loading…
Cancel
Save