stat_summary2d {ggplot2}R Documentation

Apply funciton for 2D rectangular bins.

Description

Apply function for 2D rectangular bins.

Usage

  stat_summary2d(mapping = NULL, data = NULL, geom = NULL,
    position = "identity", bins = 30, drop = TRUE,
    fun = mean, ...)

Arguments

bins

see stat_bin2d

drop

drop if the output of fun is NA.

fun

function for summary.

...

parameters passed to fun

mapping

The aesthetic mapping, usually constructed with aes or aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.

data

A layer specific dataset - only needed if you want to override the plot defaults.

geom

The geometric object to use display the data

position

The position adjustment to use for overlappling points on this layer

Aesthetics

stat_summary2d understands the following aesthetics (required aesthetics are in bold):

stat_summary2d is 2D version of stat_summary. The data are devided by x and y. z in each cell is passed to arbitral summary function.

stat_summary2d requires the following aesthetics:

See Also

stat_summary_hex for hexagonal summarization. stat_bin2d for the binning options.

Examples


d <- ggplot(diamonds, aes(carat, depth, z = price))
d + stat_summary2d()

# Specifying function
d + stat_summary2d(fun = function(x) sum(x^2))
d + stat_summary2d(fun = var)


[Package ggplot2 version 0.9.3.1 Index]