Skip to content

Commit 6607a02

Browse files
committed
change name from ggmissing to naniar
1 parent 06259fc commit 6607a02

19 files changed

Lines changed: 155 additions & 47 deletions

‎DESCRIPTION‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Package: ggmissing
1+
Package: naniar
22
Type: Package
3-
Title: enables ggplot to plot missing data
3+
Title: Enables ggplot to plot missing data
44
Version: 0.2.9000
55
Author: Nicholas Tierney, Miles McBain, Di Cook,
66
Maintainer: <nicholas.tierney@gmail.com>
7-
Description: ggmissing helps display missing data in ggplot
7+
Description: naniar helps display missing data in ggplot
88
License: MIT + file LICENSE
99
LazyData: TRUE
1010
Suggests:

‎R/geom_missing_histogram.R‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#' @name geom_missing_histogram
33
#' @description geom_missing_histogram adds a point geometry for displaying missingness.
44
#' @note Very first attempt at creating a geom that is compatible with ggplot2.
5-
#'
5+
#'
66
#' Data plotting works. Still todo:
77
#' manipulate the colour aes so that the colours and legend appear.
88
#' fix awful default point sizes.
@@ -39,10 +39,10 @@ geom_missing_histogram <- function(mapping = NULL,
3939
...
4040
)
4141
)
42-
42+
4343
}
4444

45-
#' @rdname ggmissing-ggproto
45+
#' @rdname naniar-ggproto
4646
#' @export
4747
GeomMissingHistogram <- ggproto("GeomMissingHistogram", GeomRect,
4848
required_aes = "x",

‎R/geom_missing_point.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#'
1212
# this code messes up the documentation
1313
# library(ggplot2)
14-
# library(ggmissing)
14+
# library(naniar)
1515
#
1616
# ggplot(data = brfss,
1717
# aes(x = PHYSHLTH,
@@ -50,7 +50,7 @@ geom_missing_point <- function(mapping = NULL,
5050

5151
}
5252

53-
#' @rdname ggmissing-ggproto
53+
#' @rdname naniar-ggproto
5454
#' @export
5555
GeomMissingPoint <- ggproto("GeomMissingPoint", GeomPoint,
5656
required_aes = c("x", "y"),

‎R/ggmissing-ggproto.R‎

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎R/missing_data_tidiers.R‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#'
1414
#' @examples
1515
#'
16-
#' library(ggmissing)
16+
#' library(naniar)
1717
#' percent_missing_df(airquality)
1818
#'
1919
percent_missing_df <- function(dat){
@@ -36,7 +36,7 @@ percent_missing_df <- function(dat){
3636
#'
3737
#' @examples
3838
#'
39-
#' library(ggmissing)
39+
#' library(naniar)
4040
#'
4141
#' percent_missing_var(airquality)
4242
#'
@@ -65,7 +65,7 @@ percent_missing_var <- function(dat){
6565
#'
6666
#' @examples
6767
#'
68-
#' library(ggmissing)
68+
#' library(naniar)
6969
#' percent_missing_case(airquality)
7070
#'
7171
percent_missing_case <- function(dat){

‎R/naniar-ggproto.R‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#' @name naniar-ggproto
2+
#' @title naniar-ggroto
3+
#'
4+
#' @description These are the stat and geom overrides using ggproto from ggplot2 that make naniar work.
5+
#'
6+
NULL

‎R/revealers.R‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# derive_shadows:
2+
# helpers to clear up common representations of missing values
3+
# such as "NA", "N/A", etc.
4+
# and might allow for an easier way for users to describe different
5+
# missing data codes, such as -99, which might indicate missing, but
6+
# some other kind of missing value, perhaps a different mechanism of
7+
# missingness
8+
# ideas for function names:
9+
# narify (play on clarify)
10+
# darken ()
11+
# shade
12+
# refract
13+
14+
# Other commands that might be useful?
15+
# `is_na`
16+
# `fill_na`
17+
# `drop_na`
18+
# `is_null`

‎R/shadows.R‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
# give NAs a more meaningful label
3+
is_na <- function(x) {
4+
factor(is.na(x), levels = c(FALSE, TRUE), labels = c("!NA", "NA"))
5+
}
6+
7+
# append some shadow cols
8+
9+
# return a tibble that is a shadow matrix form.
10+
11+
as_shadow <- function(data){
12+
13+
data_shadow <- purrr::map_df(data, is_na)
14+
15+
names(data_shadow) <- paste0(names(data),"_NA")
16+
17+
data_shadow
18+
19+
}
20+
21+
# as_shadow(airquality)
22+
23+
bind_shadow <- function(data){
24+
25+
# data_shadow <- map_df(data, is_na)
26+
# names(data_shadow) <- paste0(names(data),"_NA")
27+
data_shadow <- as_shadow(data)
28+
29+
bound_shadow <- tibble::as_tibble(dplyr::bind_cols(data, data_shadow))
30+
31+
bound_shadow
32+
33+
}
34+
35+
ggplot(data = bind_shadow(airquality),
36+
aes(x = Ozone)) +
37+
geom_histogram() +
38+
facet_wrap(~Solar.R_NA,
39+
ncol = 1)
40+
#
41+
ggplot(data = airquality,
42+
aes(x = Ozone)) +
43+
geom_histogram() +
44+
facet_wrap(~is_na(Solar.R),
45+
ncol = 1)
46+
#
47+
# ggplot(bind_shadow(airquality),
48+
# aes(x = Ozone,
49+
# colour = Solar.R_NA)) +
50+
# geom_density() +
51+
# geom_rug()
52+
#
53+
# ggplot(airquality,
54+
# aes(x = Ozone,
55+
# colour = is_na(Solar.R))) +
56+
# geom_density() +
57+
# geom_rug()
58+
59+
# other "long" shadow format
60+
61+
# shadow_join exists as we want to include this extra metadata about the rows that have missing data, but I also wanted to include some extra information about the class of the data, in case we need to gather the data back into a wider, rather than long, format. Here it takes a function `visdat`, `visdat:::fingerprint`, which is currently not a particularly complex function.
62+
63+
gather_shadow <- function(df){
64+
65+
df_val_type <- df %>%
66+
as_data_frame() %>%
67+
purrr::dmap(visdat:::fingerprint) %>%
68+
mutate(rows = row_number()) %>%
69+
tidyr::gather_(key_col = "variable",
70+
value_col = "valueType",
71+
gather_cols = names(.)[-length(.)])
72+
73+
# df_shadow
74+
df_shadow <- df %>%
75+
as_data_frame() %>%
76+
mutate(rows = row_number()) %>%
77+
gather(key = variable,
78+
value = value,
79+
-rows) %>%
80+
mutate(shadow_matrix = is_na(value)) %>%
81+
left_join(df_val_type)
82+
83+
# perhaps define some attributes
84+
85+
}
86+
87+
aq_shadow <- gather_shadow(airquality)

‎R/stat_missing_histogram.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ stat_missing_histogram <- function(mapping = NULL,
2929
inherit.aes = inherit.aes,
3030
params = list(na.rm = na.rm, ...)
3131
)
32-
32+
3333
}
3434

3535

36-
#' @rdname ggmissing-ggproto
36+
#' @rdname naniar-ggproto
3737
#' @export
3838
StatMissingHistogram <- ggproto("StatMissingHistogram", Stat,
3939
required_aes = c("x"),

0 commit comments

Comments
 (0)