stat_bin {ggplot2}R Documentation

stat_bin

Description

Bin data

Usage

stat_bin(mapping=NULL, data=NULL, geom="bar", position="stack", width=0.9, drop=FALSE, ...)

Arguments

mapping mapping between variables and aesthetics generated by aes
data dataset used in this layer, if not specified uses plot dataset
geom geometric used by this layer
position position adjustment used by this layer
width Width of bars when used on categorical data
drop NULL
... other arguments

Details

Missing values are currently silently dropped.

This page describes stat_bin, see layer and qplot for how to create a complete plot from individual components.

Value

A layer

Aesthetics

The following aesthetics can be used with stat_bin. Aesthetics are mapped to variables in the data with the aes function: stat\_bin(\code{aes}(x = var))

Author(s)

Hadley Wickham, http://had.co.nz/

See Also

Examples

## Not run: 
m <- ggplot(movies, aes(x=rating))
m + stat_bin()
m + stat_bin(binwidth=0.1)
m + stat_bin(breaks=seq(4,6, by=0.1))
# See geom_histogram for more histogram examples

# To create a unit area histogram, use aes(y = ..density..)
(linehist <- m + stat_bin(aes(y = ..density..), binwidth=0.1,
  geom="line", position="identity"))
linehist + stat_density(colour="blue", fill=NA)

# Also works with categorical variables
ggplot(movies, aes(x=mpaa)) + stat_bin()
qplot(mpaa, data=movies, stat="bin")

## End(Not run)

[Package ggplot2 version 0.8.2 Index]