gf_resid {coursekata} | R Documentation |
Add Residual Lines to a Plot
Description
This function adds vertical lines representing residuals from a linear model to a ggformula plot. The residuals are drawn from the observed data points to the predicted values from the model.
Usage
gf_resid(plot, model, linewidth = 0.2, ...)
Arguments
plot |
A ggformula plot object, typically created with |
model |
A fitted linear model object created using |
linewidth |
A numeric value specifying the width of the residual lines. Default is |
... |
Additional aesthetics passed to |
Value
A ggplot object with residual lines added.
Examples
Height_model <- lm(Thumb ~ Height, data = Fingers)
gf_point(Thumb ~ Height, data = Fingers) %>%
gf_model(Height_model) %>%
gf_resid(Height_model, color = "red", alpha = 0.5)
[Package coursekata version 0.19.0 Index]