plotrend | R Documentation |
The function creates a scatterplot with a superposing smoothed line as a way to reveal any potential pattern between the variables.
plotrend(
x = x,
y = y,
col.dots = "black",
linecol = "blue",
xlab = NULL,
ylab = NULL,
pch.dots = 19,
xlim = NA,
ylim = NA,
cex.dots = 1
)
x |
A numeric vector representing the X-axis variable. |
y |
A numeric vector representing the Y-axis variable (response). |
col.dots |
A string specifying the dot colors. The default value is "black". |
linecol |
A string specifying the smooth line color. The default is set to "blue". |
xlab |
(optional) A string specifying X-axis label. |
ylab |
(optional) A string specifying Y-axis label. |
pch.dots |
A numeric factor altering the shape of the dots. |
xlim |
(optional) A numeric vector having the minimum and maximum, respectively for the X-axis variable. |
ylim |
(optional) A numeric vector having the minimum and maximum, respectively for the Y-axis variable. |
cex.dots |
A numeric factor altering the size of the dots. The default value is 0.7. |
Notice that the smoothed-line is derived from a rather
standard algorithm (i.e., loess), implemented in the funcion
smoothfit
, thus it is only an approximation.
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. 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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/forestscience/54.1.107")}
df <- datana::maple
head(df)
m1<-lm(leaf~dbh,data=df)
# Example 1, a residual plot
plotrend(x=df$dbh,y=residuals(m1))
abline(h=0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.