Learn R Programming

datana (version 1.0.6)

xymultiplot: Figure of a matrix of scatterplots and histograms for several variables.

Description

The function produces a panel of multiple scatterplots and histograms, showing the correlation coefficient among all pairs of variables. Notice that the data must contain only numeric variables.

Usage

xymultiplot(
  x,
  smooth = TRUE,
  scale = FALSE,
  density = TRUE,
  digits = 2,
  method = "pearson",
  pch = 20,
  lm = FALSE,
  cor = TRUE,
  jiggle = FALSE,
  factor = 2,
  col.hist = "cyan",
  col.densi.curve = "black",
  show.points = TRUE,
  col.points = "gray",
  smoother = FALSE,
  col.smooth = "red",
  ellipses = FALSE,
  col.ellip = "blue",
  col.cent.point = "green",
  rug = TRUE,
  breaks = "Sturges",
  cex.cor = 1,
  ci = FALSE,
  alpha = 0.05,
  ...
)

Value

This function returns a multipanel of scatterplots and histograms

Arguments

x

is a dataframe containing all the numeric variables to be used for drawing the panel plot

smooth

a logical value for drawing smooth curves. The default is set to TRUE.

scale

scales the correlation font by the size of the absolute correlation. The default is set to FALSE.

density

a logical value for drawing a density curve. The default is set to TRUE.

digits

an optional numeric value for the digits to be used for drawing the correlation coefficient in the panel. Defaults is set to 2.

method

a string giving the method to be used for computing the correlation coefficient. Default is set to "pearson".

pch

The plot character (The default is 20, which looks like '.').

lm

Plot the linear fit rather than the LOESS smoothed fits. The default is FALSE.

cor

If plotting regressions, should correlations be reported? The default is TRUE.

jiggle

Should the points be jittered before plotting? The default is FALSE.

factor

factor for jittering (1-5), therefore only needed if "jiggle" is set to TRUE.

col.hist

a string giving the color to be used for the histograms of the panel. Default is set to "cyan".

col.densi.curve

a string with the name of the color to be used for the density curve. The default is set to "black".

show.points

a logical value for drawing the points in the scatter-plots. Defauls is set to TRUE.

col.points

a string giving the color to be used for the data points. Default is set to "gray".

smoother

If TRUE, then smooth.scatter the data points-slow but pretty with lots of subjects

col.smooth

a string giving the color to be used for the smoothed curve of the scatterplot. Default is set to "red".

ellipses

an optional logical value for drawing an ellipse for the scatter-plots. The default is set to FALSE.

col.ellip

a string giving the color to be used for the ellipse of the scatterplot. The default is set to "blue".

col.cent.point

a string giving the color to be used for the centroid point of the ellipse of the scatterplot. The default is set to "blue".

rug

a logical value for drawing the rugs in the histograms. Defauls is set to TRUE.

breaks

a string giving the method to be used for obtaining the breaks of the histogram. Defauls is set to "Sturges".

cex.cor

If this is specified, this will change the size of the text in the correlations. this allows one to also change the size of the points in the plot by specifying the normal cex values. If just specifying cex, it will change the character size, if cex.cor is specified, then cex will function to change the point size.

ci

Draw confidence intervals for the linear model or for the loess fit, defaults to ci=FALSE. If confidence intervals are not drawn, the fitting function is lowess.

alpha

an optional numeric value for the significance level. Defauls is set to 0.05.

...

other graphical parameters (see par and section ‘Details’ below).

Author

A modification of Christian Salas-Eljatib of the function pairs.panels of the package \(psych\).

Details

Generates a multipanel (matrix) of scatterplots and histograms to explore potential relationships among variables.

References

- Salas-Eljatib C. 2021. Análisis de datos con el programa estadístico R: una introducción aplicada. Ediciones Universidad Mayor. Santiago, Chile. https://eljatib.com

Examples

Run this code
##First example
data(bears2)
head(bears2)
df <- bears2[,c('peso','edad','cabezaL','cabezaA','largo','pechoP')]
descstat(df)
xymultiplot(df)
xymultiplot(df,ellipse=TRUE)
xymultiplot(df,ellipses=TRUE,col.cent.point = "yellow",
 col.densi.curve = "dark green",col.hist = "white")

Run the code above in your browser using DataLab