Multiple Summary Statistics for Binned Stats/Geometries

Provides the ggplot binning layer stat_summaries_hex(), which functions similar to its singular form, but allows the use of multiple statistics per bin. Those statistics can be mapped to multiple bin aesthetics.


CRAN badge Workflow badge

ggplot.multistats

ggplot.multistats currently provides stat_summaries_hex and some helpers.

stat_summaries_hex is similar to ggplot2::stat_summary_hex, but allows specifying multiple stats using the funs parameter (see Example).

Installation

ggplot.multistats is on CRAN.

install.packages('ggplot.multistats')

You can also install the development version from GitHub:

# install.packages('devtools')
devtools::install_github('flying-sheep/ggplot.multistats')

Example

Specify a summary variable using the z aesthetic and specify a list of funs to provide after_stats for you:

library(ggplot2)
library(ggplot.multistats)

ggplot(iris, aes(Sepal.Width, Sepal.Length)) +
  stat_summaries_hex(
    aes(z = Petal.Width, fill = after_stat(median), alpha = after_stat(n)),
    funs = c('median', n = 'length'),
    bins = 5
  )

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("ggplot.multistats")

1.0.1 by Philipp Angerer, 2 years ago


https://github.com/flying-sheep/ggplot.multistats


Report a bug at https://github.com/flying-sheep/ggplot.multistats/issues


Browse source code at https://github.com/cran/ggplot.multistats


Authors: Philipp Angerer [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Imports methods, rlang, scales, hexbin, ggplot2


Suggested by dittoViz.


See at CRAN