Skip to content

Multiple Summary Statistics for Binned Stats/Geometries

License

Notifications You must be signed in to change notification settings

flying-sheep/ggplot.multistats

Folders and files

NameName
Last commit message
Last commit date
Jan 5, 2023
Jan 5, 2023
Jan 5, 2023
Sep 25, 2024
May 7, 2019
Oct 8, 2024
Jan 5, 2023
Jan 5, 2023
May 7, 2019
Nov 10, 2023
May 8, 2019
May 7, 2019

Repository files navigation

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
  )