Learn R Programming

datana (version 1.0.6)

xyboxplot: Creates a scatterplot with superposing boxplots

Description

The function creates a scatterplot with superposing boxplots for the Y-axis variable. To a simple scatterplot between the response variable 'y' and the predictor variable 'x', this function superposes boxplots of the response by groups of the predictor variable. The main aim of the above described graph is to get a sense of the distribution of the response variable depending upon the predictor variable.

Usage

xyboxplot(x = x, y = y, col.dots = "blue", xlab = NULL, ylab = NULL)

Value

The function returns the above described graph.

Arguments

x

A numeric vector representing the time variable (X-axis).

y

A numeric vector representing the response variable (Y-axis).

col.dots

(optional) A string specifying the dot colors. Default is "blue".

xlab

(optional) A string specifying X-axis label.

ylab

(optional) A string specifying Y-axis label.

Author

Christian Salas-Eljatib

Details

Notice that the superposing boxplots for the Y-axis variable are computed by grouping the X-axis variable in 10 classes. Those classes are set by computing the ten percentiles of the X-axis variable, therefore each group has the same number of observations.

References

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

- Salas C, Stage AR, and Robinson AP. 2008. Modeling effects of overstory density and competing vegetation on tree height growth. Forest Science 54(1):107-122. tools:::Rd_expr_doi("10.1093/forestscience/54.1.107")

Examples

Run this code
data(fishgrowth)
df <- fishgrowth
xyboxplot(x=df$age,y=df$length)
xyboxplot(x=df$age,y=df$length)

Run the code above in your browser using DataLab