marginal.plot {latticeExtra}R Documentation

Display marginal distributions

Description

Display marginal distributions of several variables, which may be numeric and/or categorical, on one plot.

Usage

marginal.plot(x,
              data = NULL,
              groups = NULL,
              reorder = !is.table(x),
              plot.points = FALSE,
              ref = TRUE,
              origin = 0,
              xlab = NULL, ylab = NULL,
              type = c("p", if (is.null(groups)) "h"),
              ...,
              subset = TRUE,
              as.table = TRUE,
              subscripts = TRUE,
              default.scales = list(
                relation = "free",
                abbreviate = TRUE, minlength = 5,
                rot = 30, cex = 0.75, tick.number = 3,
                y = list(draw = FALSE)),
             lattice.options = list(
               layout.heights = list(
                 axis.xlab.padding = list(x = 0),
                 xlab.key.padding = list(x = 0))))

Arguments

x a data frame or table, or a formula of which the first term is a data frame or table. Otherwise coerced with as.data.frame.
data an optional data source in which groups and subset may be be evaluated.
groups term, to be evaluated in data, that is used as a grouping variable.
reorder whether to reorder factor variables by frequency.
subset data subset expression, evaluated in data.
plot.points, ref passed to panel.densityplot.
origin, type passed to panel.dotplot.
xlab, ylab, as.table, subscripts see xyplot.
default.scales, lattice.options see xyplot.
... passed to panel.densityplot and/or panel.dotplot.

Details

In the case of mixed numeric and categorical variables, the trellis objects from dotplot() and densityplot() are merged.

Value

a trellis object.

Author(s)

Felix Andrews

See Also

panel.dotplot, panel.densityplot

Alias

marginal.plot

Keyword

hplot

Examples

enviro <- environmental
## make an ordered factor (so it will not be reordered)
enviro$smell <- cut(enviro$ozone, breaks = c(0, 30, 50, Inf),
    labels = c("ok", "hmmm", "yuck"), ordered = TRUE)
marginal.plot(enviro)

## using groups
enviro$is.windy <- factor(enviro$wind > 10,
    levels = c(TRUE, FALSE), labels = c("windy", "calm"))
marginal.plot(enviro[,1:5], data = enviro, groups = is.windy,
    auto.key = list(lines = TRUE))

## support for tables
marginal.plot(Titanic)
## table with groups
marginal.plot(~ Titanic, data = Titanic, groups = Survived,
    type = "b", auto.key = list(title = "Survived?"))

Results


R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(latticeExtra)
> png(filename="images/marginal.plot_%03d.png" ,width=480, height=480)
> ### Name: marginal.plot
> ### Title: Display marginal distributions
> ### Aliases: marginal.plot
> ### Keywords: hplot
> 
> ### ** Examples
> 
> enviro <- environmental
> ## make an ordered factor (so it will not be reordered)
> enviro$smell <- cut(enviro$ozone, breaks = c(0, 30, 50, Inf),
+     labels = c("ok", "hmmm", "yuck"), ordered = TRUE)
> marginal.plot(enviro)
> 
> ## using groups
> enviro$is.windy <- factor(enviro$wind > 10,
+     levels = c(TRUE, FALSE), labels = c("windy", "calm"))
> marginal.plot(enviro[,1:5], data = enviro, groups = is.windy,
+     auto.key = list(lines = TRUE))
> 
> ## support for tables
> marginal.plot(Titanic)
> ## table with groups
> marginal.plot(~ Titanic, data = Titanic, groups = Survived,
+     type = "b", auto.key = list(title = "Survived?"))
> 
> 
> 
> dev.off()
null device 
          1 
> 





[Package latticeExtra Index]