condition: Conditioned Graphs

View source: R/condition.R

conditionR Documentation

Conditioned Graphs

Description

Facilitates producing a series of graphs conditioned by a grouping variable.

Usage

condition(plot.call, data, group, format = "grid", num.cols = NA,
  num.rows = NA, explanation = NULL, share = "", group.name = "",
  xtitle = "", ytitle = "", caption = "")

Arguments

plot.call

either a simple call to a graphics function or a sequence of calls enclosed in curly braces({})

data

the data.frame containing the variables used in plot.call and group.

group

a character string identifying the grouping variable in data.

format

the orientation of the graphs. If "table," then the graphs are created beginning in the upper-left hand corner. If "grid," then the graphs are created beginning in the lower-left See Details. hand corner.

num.cols

the number of columns on each page. See Details.

num.rows

the number of rows on each page. See Details.

explanation

where to place an explanation if necessary. See setLayout for details.

share

character, if share contains "x", then the code in plot.call is set up to share x-axes; if share contains "y", then the code in plot.call is set up to share y-axes. The default is not to share either axes.

group.name

a character string to prepend to each value in group to create the graph title.

xtitle

the x-axis title (also called x-axis caption).

ytitle

the y-axis title (also called y-axis caption).

caption

the figure caption.

Details

Graphs are created by executing plot.call for each unique value in the variable specified by group. The columns and rows are set by num.cols and num.rows. If both are set to missing NA, then each page contains 1 graph, and the graphics setup should provide for mulitple pages. If one of num.cols or num.rows is set to a numeric value, the other is calculated from the number of graphs so that all graphs would be displayed on a single page. If both num.cols and num.rows are set to numeric values, then each page would contain a maximum of num.cols times num.rows and multiple pages would be needed if that were less than the total number of graphs.

The order of the graphs is controlled by the type of group. If group is a factor, then the order is set by the order of the levels, otherwise the order is set by the order from unique.

Value

The value returned by plot.call is returned invisibly. If used correctly, it could be used to add an explanation.

Note

This function is designed to facilitate the production of conditioned graphs, but may not render each collection completely. For example, graphs arranged in table format will not have x-axis labels for incomplete columns.

A call must be made to setPage or setPDF to set up the graphics page before calling condition. The returned value can be used to create an explanation, if desired. If explanation is not NULL, then the graph is set to the explanation and there is no need to call setGraph to set up the explanation.

The called plotting function must set the margin argument to .margin. See the demos for examples.

References

Cleveland, W.S., 1993, Visualizing data: Summit, New Jersey, Hobart Press, 360 p.

See Also

setLayout, setPage, setPDF, unique

Examples

## Not run: 
# See for examples of condition:
demo(topic="Coplot-complexScatterPlot", package="smwrGraphs")
demo(topic="Coplot-simpleBoxPlot", package="smwrGraphs")

## End(Not run)

USGS-R/smwrGraphs documentation built on Oct. 11, 2022, 6:11 a.m.