add_curve | R Documentation |
Include a line or curve created from a linear model with a single response
and a single explanatory variable. The mod
function should be created
by using the lm
function. To plot a polynomial curve, use the
poly
function with the explanatory variable. See the examples below
for additional usage details.
add_curve(mod, col = "black", plot_base = trellis.last.object())
mod |
Model. A linear model with a single response and a single explanatory variable. |
col |
Character. The name of a color to use when plotting the line/curve. |
add_line
, lm
, poly
# Create a linear model and use the model plot the line on a xyplot
m_line <- lm(weight ~ height, data = cdc)
xyplot(weight ~ height, data = cdc)
add_curve(m_line)
# Create a linear model with a quadratic polynomial and include the curve on
# the xyplot.
m_curve <- lm(weight ~ poly(height, 2), data = cdc)
xyplot(weight ~ height, data = cdc)
add_curve(m_curve)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.