panels: More panel plots.

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

Description

Several panel plots that can be used with functions like coplot() and [pairs))].

[pairs))]: R:pairs))

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
panel_reg(x, y, col = par("col"), bg = par("bg"), pch = par("pch"),
  cex = par("cex"), lwd = par("lwd"), line.reg = lm, line.col = "red",
  line.lwd = lwd, untf = TRUE, ...)

panel.reg(x, y, col = par("col"), bg = par("bg"), pch = par("pch"),
  cex = par("cex"), lwd = par("lwd"), line.reg = lm, line.col = "red",
  line.lwd = lwd, untf = TRUE, ...)

panel_ellipse(x, y, col = par("col"), bg = par("bg"), pch = par("pch"),
  cex = par("cex"), el.level = 0.7, el.col = "cornsilk",
  el.border = "red", major = TRUE, ...)

panel.ellipse(x, y, col = par("col"), bg = par("bg"), pch = par("pch"),
  cex = par("cex"), el.level = 0.7, el.col = "cornsilk",
  el.border = "red", major = TRUE, ...)

panel_cor(x, y, use = "everything", method = c("pearson", "kendall",
  "spearman"), alternative = c("two.sided", "less", "greater"), digits = 2,
  prefix = "", cex = par("cex"), cor.cex = cex, stars.col = "red", ...)

panel.cor(x, y, use = "everything", method = c("pearson", "kendall",
  "spearman"), alternative = c("two.sided", "less", "greater"), digits = 2,
  prefix = "", cex = par("cex"), cor.cex = cex, stars.col = "red", ...)

panel_smooth(x, y, col = par("col"), bg = NA, pch = par("pch"), cex = 1,
  col.smooth = "red", span = 2/3, iter = 3, ...)

Arguments

x

A numeric vector.

y

A numeric vector of same length as x.

col

The color of the points.

bg

The background color for symbol used for the points.

pch

The symbol used for the points.

cex

The expansion factor used for the points.

lwd

The line width.

line.reg

A function that calculates coefficients of a straight line, for instance, lm(), or rlm() for robust linear regression.

line.col

The color of the line.

line.lwd

The width of the line.

untf

Logical asking whether to untransform the straight line in case one or both axis are in log scale.

...

Further arguments to plot functions.

el.level

The confidence level for the bivariate normal ellipse around data; the default value of 0.7 draws an ellipse of roughly +/-1 sd.

el.col

The color used to fill the ellipse.

el.border

The color used to draw the border of the ellipse and the standardized major axis.

major

If TRUE, the standardized major axis is also drawn.

use

One of "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs" (can be abbreviated). Defines how the cor() function behaves with missing observations.

method

One of the three correlation coefficients "pearson" (default), "kendall", or "spearman". Can be abbreviated.

alternative

The alternative hypothesis in correlation test, see cor.test().

digits

The number of decimal digits to print when the correlation coefficient is printed in the graph.

prefix

A prefix (character string) to use before the correlation coefficient printed in the graph.

cor.cex

Expansion coefficient for text in printing correlation coefficients.

stars.col

The color used for significance stars (with: *** p < 0.001, ** p < 0.1, * p < 0.05, . p < 0.1.

col.smooth

Color to be used by lines for drawing the smooths.

span

Smoothing parameter f for lowess(), see there.

iter

Number of robustness iterations for lowess().

Details

Theses functions should be used outside of the diagonal in pairs(), or with coplot(), as they are bivariate plots.

Value

These functions return nothing and are used for their side effect of plotting in panels of composite plots.

Author(s)

Philippe Grosjean phgrosjean@sciviews.org, but code inspired from panel.smooth() in graphics and panel.car() in package car.

See Also

coplot(), pairs(), panel.smooth(), lm(), ellipse(), cor() and cor.test()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Smooth lines in lower graphs and straight lines in upper graphs
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_reg)
# Robust regression lines
library(MASS)  # For rlm()
pairs(trees, panel = panel_reg, diag.panel = panel_boxplot,
  reg.line = rlm, line.col = "blue", line.lwd = 2)
# A Double log graph
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_reg, log = "xy")

# Graph suitables to explore correlations (take care there are potentially
# many simultaneous tests done here... So, you loose much power in the whole
# analysis... use it just as an indication!)
# Pearson's r
pairs(trees, lower.panel = panel_ellipse, upper.panel = panel_cor)
# Spearman's rho (ellipse and straight lines not suitable here!)
pairs(trees, lower.panel = panel_smooth, upper.panel = panel_cor,
  method = "spearman", span = 1)
# Several groups (visualize how bad it is to consider the whole set at once!)
pairs(iris[, -5], lower.panel = panel_smooth, upper.panel = panel_cor,
  method = "kendall", span = 1,
  col = c("red3", "blue3", "green3")[iris$Species])
# Now analyze correlation for one species only
pairs(iris[iris$Species == "virginica", -5], lower.panel = panel_ellipse,
  upper.panel = panel_cor)

# A coplot with custom panes
coplot(Petal.Length ~ Sepal.Length | Species, data = iris,
  panel = panel_ellipse)

SciViews documentation built on Nov. 17, 2019, 1:06 a.m.