latticistCompose: Latticist API

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/latticistCompose.R

Description

Convert a simple specification list into a Lattice plot call, or the inverse operation.

Usage

1
2
3
latticistCompose(dat, spec = list(),
                 datArg = substitute(dat),
                 enclos = parent.frame())

Arguments

dat

a data frame (with numeric and/or categorical variables).

spec

a list specifying the latticist plot. See Details.

datArg

the symbol to use for dat in the generated call.

enclos

an environment to use as an enclosure around dat for evaluating expressions.

Details

Elements of spec can include:

xvar, yvar, zvar

variables (or expressions) for the x, y and z axes. If all are missing, a hypervariate plot is produced according to defaultPlot (see below). Note that x or y may be discretized by setting doXDisc or doYDisc (see below).

groups

a grouping variable or color-coding covariate. This can refer to either a categorical or numeric variable. Many plot types support continuous color covariates, in which case a colorkey will be drawn. For categorical groups a standard key will be drawn.

cond, cond2

conditioning variables. These will be turned into shingles if required, with nLevels distinct levels (see below).

subset

subset expression.

varSubset

a character vector, the subset of variables (from the data frame) to include in hypervariate plots.

defaultPlot

one of "marginal.plot", "splom" or "parallel". Specifies the type of plot to produce if xvar and yvar are missing. Note that groups is supported by all these plots, and cond is supported by "splom" and "parallel".

NOTE: when the data is a table, "parallel" does not produce a parallel plot, but rather a stacked barchart of the table. Also when the data is a table, "splom" produces a pairs layout of mosaic plots.

aspect

panel aspect ratio, as a numeric value (= y / x), or one of the values "fill", "iso", "xy".

doLines

whether to add lines to relevant plot types (i.e. those involving numeric variables). For dotplot and cloud this refers to droplines (type "h") (though if groups are defined in a dotplot, type "l" is used). In a grouped stripplot, group medians are joined (type "a", fun = median). For qqmath the points are joined in order (type "l"). For xyplot and similar, the line type depends on the nature of the data; if the data x values form a regular sequence or are few in number they are simply joined (type "l"); if duplicate x values are detected, with a reasonable number of unique values, their averages are joined (type "a"); otherwise a smoothing line is added according to latticist.getOption("xyLineType"). This defaults to "smooth" (loess fit), but could reasonably be set to "r" (regression line) or "a" (joined averages).

doHexbin

whether to use hexbinplot rather than xyplot for bivariate numeric plots. These can be faster and more effective for large datasets. Note that groups are not supported.

doSegments, doAsError

if doSegments is TRUE when all of xvar, yvar and zvar are defined, a segplot is produced where the x values are joined to z values by horizontal segments. Alternatively, if doAsError is TRUE, segments are drawn from (x - z) to (x + z), and each x point is marked, such that z acts as an error or range about x.

doTile

when drawing a bivariate numeric plot with a color-covariate (i.e. when xvar, yvar and groups are all numeric), this option will draw a tileplot, which draws a polygon enclosing each point. This may be appropriate when x and y are on the same scale.

doXDisc, doYDisc

set to discretize xvar and/or yvar, if they are numeric. Either cut or equal.count is used, depending on the plot type, with nLevels distinct levels.

nLevels

number of levels for discretizing cond and cond2, optionally xvar or yvar, and in some cases groups. For shingles, the amount of overlap is taken from latticist.getOption("shingle.overlap").

x.relation, y.relation

defines the scales in conditioned lattice plots. Can have values in "free", "same" or "sliced".

doSeparateStrata

when a mosaic plot is produced and cond or cond2 are defined, this defines whether to separate the strata defined by conditioning variables into different panels (the default; uses cotabplot), or to include the conditioning variables in the one mosaic plot (doSeparateStata = FALSE).

Note that xvar, yvar, zvar, groups, cond, cond2, subset must be character strings (or NULL), and will be parsed.

Value

latticistCompose returns a call.

Author(s)

Felix Andrews felix@nfrac.org

References

For an excellent introduction to and coverage of Lattice:

Sarkar, Deepayan (2008) "Lattice: Multivariate Data Visualization with R", Springer. http://lmdvr.r-forge.r-project.org/

See Also

latticist, Lattice

Examples

1
2
3
4
5
6
7
8
9
latticistCompose(CO2)

latticistCompose(CO2, spec = list(defaultPlot = "parallel"))

latticistCompose(CO2, spec = list(xvar = "uptake"))

latticistCompose(CO2, spec = list(yvar = "uptake"))

latticistCompose(CO2, spec = list(yvar = "uptake", doYDisc = TRUE))

11010tianyi/latticist documentation built on May 5, 2019, 10:36 a.m.