Learn R Programming

mosaic (version 0.14)

ashplot: Average Shifted Histograms

Description

An ASH plot is the average over all histograms of a fixed bin width.

Mainly a utility for the lattice and ggplot2 plotting functions, ash_points() returns the points to be plotted.

Usage

ashplot(x, ..., width = NULL, adjust = NULL, panel = panel.ashplot, prepanel = prepanel.default.ashplot)
prepanel.default.ashplot(x, darg, groups = NULL, subscripts = TRUE, ...)
panel.ashplot(x, darg = list(), plot.points = FALSE, ref = FALSE, groups = NULL, jitter.amount = 0.01 * diff(current.panel.limits()$ylim), type = "p", ..., identifier = "ash")
ash_points(x, binwidth = NULL, adjust = 1)
StatAsh
stat_ash(mapping = NULL, data = NULL, geom = "line", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, binwidth = NULL, adjust = 1, ...)
geom_ash(mapping = NULL, data = NULL, stat = "ash", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, binwidth = NULL, adjust = 1, ...)

Arguments

x
a formula or numeric vector
...
additional arguments passed to panel and prepanel functions or data, a data frame in which to find the variales used for the plot.
width
the historam bin width.
adjust
a numeric adjustment to width. Primarily useful when width is not specified. Increasing adjust makes the plot smoother.
panel
a panel funtion
prepanel
a prepanel function
darg
a list of arguments for the function computing the ASH.
groups
as in other lattice plots
subscripts
as in other lattice prepanel functions
plot.points
One of TRUE, FALSE, "jitter", or "rug"
ref
a logical indicating whether a reference line should be displayed
jitter.amount
when plot.points="jitter", the value to use as the amount argument to jitter.
type
type argument used to plot points, if requested. This is not expected to be useful, it is available mostly to protect a type argument, if specified, from affecting the display of the ASH.
identifier
A character string that is prepended to the names of i grobs that are created by this panel function.
binwidth
the width of the histogram bins. If NULL (the default) the binwidth will be chosen so that approximately 10 bins cover the data. adjust can be used to to increase or decrease binwidth.
mapping
set of aesthetic mappings created by aes() or aes_().
data
a data frame
geom
a geom to use for this layer, as a string.
position
position adjustment, either as a string or the result of a call to a position adjustment function.
na.rm
If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values.
show.legend
logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes.
inherit.aes
If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.
stat
a statistical transformation to use on the data for this layer, as a string.

Value

a data frame containing x and y coordinates of the resulting ASH plot.

Format

An object of class StatAsh (inherits from Stat, ggproto) of length 3.

Examples

Run this code
ashplot( ~age | substance, groups = sex, data = HELPrct)
ggplot(faithful, aes(x = eruptions)) +
  geom_histogram(aes(y = ..density..), 
    fill = "lightskyblue", colour = "gray50", alpha = 0.2) +
  geom_ash(colour = "red") + 
  geom_ash(colour = "forestgreen", adjust = 2) + 
  geom_ash(colour = "navy", adjust = 1/2) + 
  theme_minimal()

Run the code above in your browser using DataLab