xyhist | R Documentation |
The function produces a scatterplot between the 'y'-axis variable and the 'x'-axis variable, but also adding the marginal histograms for both variables.
xyhist(
x = x,
y = y,
col.x = "blue",
col.y = "red",
xlab = NULL,
ylab = NULL,
x.lim = NULL,
y.lim = NULL
)
x |
A numeric vector representing the X-axis variable |
y |
A numeric vector representing the Y-axis variable |
col.x |
(optional) A string specifying the color of the histogram of the X-variable. Default is "blue". |
col.y |
(optional) A string specifying the color of the histogram of the Y-variable. Default is "red". |
xlab |
(optional) A string specifying X-axis label. Default is "xvar". |
ylab |
(optional) A string specifying Y-axis label. Default is "yvar". |
x.lim |
(optional) A vector of two elements with the limits of the Y-axis. Default is the range of the X-variable. |
y.lim |
(optional) A vector of two elements with the limits of the Y-axis. Default is the range of the Y-variable. |
Both the response variable (Y-axis) and the predictor variable (X-axis) must be numeric.
The function returns the above described graph.
Christian Salas-Eljatib
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
data(treevolroble)
df <- datana::treevolroble
head(df)
xyhist(x=df$dbh,y=df$toth)
xyhist(x=df$dbh,y=df$toth, xlab="Variable X", ylab="Variable Y")
xyhist(x=df$dbh,y=df$toth, xlab="Variable X", ylab="Variable Y",
col.x = "gray",col.y="white")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.