Skip to content

Commit

Permalink
change geom_missing_point to geom_miss_point
Browse files Browse the repository at this point in the history
  • Loading branch information
njtierney committed Jul 24, 2017
1 parent d636faa commit 9f39774
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 57 deletions.
8 changes: 4 additions & 4 deletions NAMESPACE
Expand Up @@ -8,8 +8,8 @@ S3method(shadow_shift,default)
S3method(shadow_shift,factor)
S3method(shadow_shift,numeric)
export("%>%")
export(GeomMissingPoint)
export(StatMissingPoint)
export(GeomMissPoint)
export(StatMissPoint)
export(add_any_miss)
export(add_label_missings)
export(add_label_shadow)
Expand All @@ -24,7 +24,7 @@ export(cast_shadow_shift)
export(cast_shadow_shift_label)
export(draw_key_missing_point)
export(gather_shadow)
export(geom_missing_point)
export(geom_miss_point)
export(gg_miss_case)
export(gg_miss_fct)
export(gg_miss_span)
Expand All @@ -51,7 +51,7 @@ export(prop_complete)
export(prop_miss)
export(replace_to_na)
export(shadow_shift)
export(stat_missing_point)
export(stat_miss_point)
export(vis_miss)
import(ggplot2)
import(rlang)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
@@ -1,10 +1,14 @@
# narnia 0.0.9.9300 (2017/07/24)
# narnia 0.0.9.4000 (2017/07/24)

## new features

- `replace_to_na` is a complement to `tidyr::replace_na` and replaces a specified
value from a variable to NA.

## breaking changes

- changed `geom_missing_point()` to `geom_miss_point()`.

# narnia 0.0.9.9201 (2017/07/12)

## new features
Expand Down
18 changes: 9 additions & 9 deletions R/geom-missing-point.R
@@ -1,10 +1,10 @@
#' Plot Missing Data Points
#'
#' \code{geom_missing_point} adds a missing data point geometry to ggplot2. This displays missing data points 10% below the minimum value.
#' \code{ geom_miss_point} adds a missing data point geometry to ggplot2. This displays missing data points 10% below the minimum value.
#'
#' @include legend-draw.R
#' @name geom_missing_point
#' @title geom_missing_point
#' @name geom_miss_point
#' @title geom_miss_point
#' @note Warning message if na.rm = T is supplied.
#'
#' @param mapping Set of aesthetic mappings created by \code{\link[ggplot2]{aes}}
Expand Down Expand Up @@ -55,14 +55,14 @@
#' y = Solar.R)) +
#' geom_point()
#'
#' # using geom_missing_point()
#' # using geom_miss_point()
#' ggplot(airquality,
#' aes(x = Ozone,
#' y = Solar.R)) +
#' geom_missing_point()
#' geom_miss_point()
#'
#' @export
geom_missing_point <- function(mapping = NULL,
geom_miss_point <- function(mapping = NULL,
data = NULL,
# stat = "identity",
position = "identity",
Expand All @@ -74,8 +74,8 @@ geom_missing_point <- function(mapping = NULL,
layer(
data = data,
mapping = mapping,
stat = StatMissingPoint,
geom = GeomMissingPoint,
stat = StatMissPoint,
geom = GeomMissPoint,
position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand All @@ -91,7 +91,7 @@ geom_missing_point <- function(mapping = NULL,
#' @format NULL
#' @usage NULL
#' @export
GeomMissingPoint <- ggproto("GeomMissingPoint", GeomPoint,
GeomMissPoint <- ggproto("GeomMissPoint", GeomPoint,
required_aes = c("x", "y"),
default_aes = aes(shape = 19,
colour = ..missing..,
Expand Down
12 changes: 6 additions & 6 deletions R/stat-missing-point.R
@@ -1,6 +1,6 @@
#' @name stat_missing_point
#' @title stat_missing_point
#' @description stat_missing_point adds a geometry for displaying missingness to geom_point
#' @name stat_miss_point
#' @title stat_miss_point
#' @description stat_miss_point adds a geometry for displaying missingness to geom_point
#'
#' @note Very first attempt at creating a geom that is compatible with ggplot2.
#' Data plotting works. Still todo:
Expand Down Expand Up @@ -43,7 +43,7 @@
#' }
#'
#' @export
stat_missing_point <- function(mapping = NULL,
stat_miss_point <- function(mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
Expand All @@ -52,7 +52,7 @@ stat_missing_point <- function(mapping = NULL,
inherit.aes = TRUE,
...) {
ggplot2::layer(
stat = StatMissingPoint,
stat = StatMissPoint,
data = data,
mapping = mapping,
geom = geom,
Expand All @@ -66,7 +66,7 @@ stat_missing_point <- function(mapping = NULL,

#' @rdname narnia-ggproto
#' @export
StatMissingPoint <- ggproto("StatMissingPoint", Stat,
StatMissPoint <- ggproto("StatMissPoint", Stat,
required_aes = c("x", "y"),
default_aes = aes(colour = ..missing..),
setup_data = function(data, params){
Expand Down
16 changes: 8 additions & 8 deletions README.Rmd
Expand Up @@ -27,7 +27,7 @@ Currently it provides:
+ `gather_shadow()`
+ `is_na()`
- Visualisation methods:
+ `geom_missing_point()`
+ `geom_miss__point()`
+ `gg_miss_var()`
+ `gg_miss_case()`
+ `gg_miss_which()`
Expand Down Expand Up @@ -66,7 +66,7 @@ __Illustration of data structures for facilitating visualisation of missings and

# Visualising missing data

Visualising missing data might sound a little strange - how do you visualise something that is not there? One approach to visualising missing data comes from ggobi and manet, where we replace "NA" values with values 10% lower than the minimum value in that variable. This is provided with the `geom_missing_point()` ggplot2 geom, which we can illustrate by exploring the relationship between Ozone and Solar radiation from the airquality dataset.
Visualising missing data might sound a little strange - how do you visualise something that is not there? One approach to visualising missing data comes from ggobi and manet, where we replace "NA" values with values 10% lower than the minimum value in that variable. This is provided with the `geom_miss_point()` ggplot2 geom, which we can illustrate by exploring the relationship between Ozone and Solar radiation from the airquality dataset.


```{r regular-geom-point}
Expand All @@ -82,7 +82,7 @@ ggplot(data = airquality,

ggplot2 does not handle these missing values, and we get a warning message about the missing values.

We can instead use the `geom_missing_point()` to display the missing data
We can instead use the `geom_miss_point()` to display the missing data

```{r geom-missing-point}
Expand All @@ -91,11 +91,11 @@ library(narnia)
ggplot(data = airquality,
aes(x = Ozone,
y = Solar.R)) +
geom_missing_point()
geom_miss_point()
```

`geom_missing_point()` has shifted the missing values to now be 10% below the minimum value. The missing values are a different colour so that missingness becomes pre-attentive.
`geom_miss_point()` has shifted the missing values to now be 10% below the minimum value. The missing values are a different colour so that missingness becomes pre-attentive.

This plays nicely with other parts of ggplot, like adding transparency

Expand All @@ -104,7 +104,7 @@ This plays nicely with other parts of ggplot, like adding transparency
ggplot(data = airquality,
aes(x = Ozone,
y = Solar.R)) +
geom_missing_point(alpha = 0.5)
geom_miss_point(alpha = 0.5)
```

Expand All @@ -120,7 +120,7 @@ p1 <-
ggplot(data = airquality,
aes(x = Ozone,
y = Solar.R)) +
geom_missing_point() +
geom_miss_point() +
facet_wrap(~Month, ncol = 2) +
theme(legend.position = "bottom")
Expand Down Expand Up @@ -286,7 +286,7 @@ gg_miss_which(airquality)

# Future Work

Other plans to extend the `geom_missing_` family to include:
Other plans to extend the `geom_miss_` family to include:

- Categorical variables
- Bivariate plots: Scatterplots, Density overlays.
Expand Down
3 changes: 1 addition & 2 deletions _pkgdown.yml
Expand Up @@ -7,8 +7,7 @@ reference:
desc: >
Visualise missing data
contents:
- geom_missing_point
- stat_missing_point
- geom_miss_point
- starts_with("gg_miss_")
- title: "Numerical Summaries"
desc: >
Expand Down
2 changes: 1 addition & 1 deletion inst/shadow-mechanics.Rmd
Expand Up @@ -326,7 +326,7 @@ airquality %>%

Which is rather involved, and not ideal, because you are no longer trying to explore missing data, you have now spent time working out how to correctly shift missing values, keep track of what was missing, and then plot this, then add colour, and identify which values are missing.

To make this simpler, you use the ggplot2 geom `geom_missing_point()`. This `geom` allows for missing values to be displayed, and also works with the rest of ggplot2 - themes, and facets as well.
To make this simpler, you use the ggplot2 geom `geom_miss_point()`. This `geom` allows for missing values to be displayed, and also works with the rest of ggplot2 - themes, and facets as well.

**What is imputed, stays imputed**

Expand Down
14 changes: 7 additions & 7 deletions man/geom_missing_point.Rd → man/geom_miss_point.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/narnia-ggproto.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/stat_missing_point.Rd → man/stat_miss_point.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-plots.R
@@ -1,14 +1,14 @@
context("narnia-plots")

library(ggplot2)
geom_missing_point_plot <-
geom_miss_point_plot <-
ggplot(airquality,
aes(x = Solar.R,
y = Ozone)) +
geom_missing_point()
geom_miss_point()

test_that("geom_miss_point works",{
vdiffr::expect_doppelganger("geom_missing_point", geom_missing_point_plot)
vdiffr::expect_doppelganger("geom_miss_point", geom_miss_point_plot)
})


Expand Down
12 changes: 6 additions & 6 deletions vignettes/getting-started-w-narnia.Rmd
Expand Up @@ -111,7 +111,7 @@ ggplot(airquality,

The problem with this is that ggplot does not handle missings be default, and removes the missing values. This makes them hard to explore.

Visualising missing data might sound a little strange - how do you visualise something that is not there? One approach to visualising missing data comes from ggobi and manet, where we replace "NA" values with values 10% lower than the minimum value in that variable. This is provided with the `geom_missing_point()` ggplot2 geom, which we can illustrate by exploring the relationship between Ozone and Solar radiation from the airquality dataset.
Visualising missing data might sound a little strange - how do you visualise something that is not there? One approach to visualising missing data comes from ggobi and manet, where we replace "NA" values with values 10% lower than the minimum value in that variable. This is provided with the `geom_miss_point()` ggplot2 geom, which we can illustrate by exploring the relationship between Ozone and Solar radiation from the airquality dataset.

```{r echo = TRUE, out.width = "50%", fig.show='hold'}
Expand All @@ -125,7 +125,7 @@ library(narnia)
ggplot(airquality,
aes(x = Solar.R,
y = Ozone)) +
geom_missing_point()
geom_miss_point()
```

Expand All @@ -136,7 +136,7 @@ ggplot(airquality,
ggplot(airquality,
aes(x = Solar.R,
y = Ozone)) +
geom_missing_point() +
geom_miss_point() +
facet_wrap(~Month)
```
Expand All @@ -148,7 +148,7 @@ ggplot(airquality,
ggplot(airquality,
aes(x = Solar.R,
y = Ozone)) +
geom_missing_point() +
geom_miss_point() +
facet_wrap(~Month) +
theme_dark()
Expand Down Expand Up @@ -410,12 +410,12 @@ The tools in `narnia` help us identify where missingness is, while maintaining a

- Continue making `narnia` play well with `dplyr` and `tidyr`.
- Make `narnia` work with big data tools like `sparklyr`, and `sparklingwater`.
- Expand ggplot `geom_missing_*` family.
- Expand ggplot `geom_miss_*` family.
- Further develop methods for handling and visualising imputations, and multiple imputation.

# Thank you

A huge thanks of course to Di Cook and Miles McBain for their assistance on this project, and its development. In particular, I thank Di for providing the large conceptual ideas of how to display missings, and the use of the shadow matrix. I also thank Miles for his instrumental work in getting `stat_missing_point` and `geom_missing_point()` working as they do now.
A huge thanks of course to Di Cook and Miles McBain for their assistance on this project, and its development. In particular, I thank Di for providing the large conceptual ideas of how to display missings, and the use of the shadow matrix. I also thank Miles for his instrumental work in getting `stat_missing_point` and `geom_miss_point()` working as they do now.

# References

Expand Down

0 comments on commit 9f39774

Please sign in to comment.