Skip to content

Commit

Permalink
Minor fixes and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmlft committed Nov 23, 2020
1 parent c2833a3 commit 3fcd958
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 6 additions & 7 deletions R/stat-propzero.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Annotating ggplots with prop. of zeros
#'
#' @inheritParams ggplot2::stat_identity
#' @inheritParams ggplot2::stat_count
#' @section Computed variables:
#' `stat_propzero()` provides the following variables:
#' \describe{
Expand All @@ -11,21 +11,20 @@
stat_propzero <- function(mapping = NULL, data = NULL, geom = "text",
position = "identity", na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE, ...) {
# TODO: replace `layer` with `annotate`?
# Might allow more flexible positioning of text annotation
# TODO: find way to allow more flexible positioning of labels
ggplot2::layer(
stat = StatPropZero, data = data, mapping = mapping, geom = geom,
stat = StatPropzero, data = data, mapping = mapping, geom = geom,
position = position, show.legend = show.legend, inherit.aes = inherit.aes,
params = list(na.rm = na.rm, ...)
)
}

# FIXME: figure out how to supply `format` arugment to format the proportions
# FIXME: figure out how to supply `format` argument to format the proportions
# e.g. as percentages or rounded decimals
# ggproto object for stat_propzero
StatPropZero <- ggplot2::ggproto("StatPropZero", ggplot2::Stat,
StatPropzero <- ggplot2::ggproto("StatPropzero", ggplot2::Stat,
required_aes = c("x", "y"),
default_aes = aes(label = stat(propzero)),
default_aes = aes(label = after_stat(propzero)),

compute_group = function(data, scales) {
grouped <- dplyr::group_by(data, x)
Expand Down
6 changes: 5 additions & 1 deletion man/stat_propzero.Rd

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

0 comments on commit 3fcd958

Please sign in to comment.