gf_model_old | R Documentation |
gf_model()
When teaching about regression it can be useful to visualize the data as a point plot with the
outcome on the y-axis and the explanatory variable on the x-axis. For regression models, this is
most easily achieved by calling gf_lm()
, with empty models gf_hline()
using the mean, and
a more complicated call to gf_segment()
for group models. This function simplifies this by
making a guess about what kind of model you are plotting (empty/null, regression, group) and then
making the appropriate plot layer for it. Note: this function only works with models that
have a single or NULL
explanatory variable, and it will not work with multiple regression.
gf_model_old(
object = NULL,
gformula = NULL,
data = NULL,
model = NULL,
width = 0.3,
...
)
object |
When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples. |
gformula |
A formula with shape y ~ x. Superseded by |
data |
A data frame with the variables to be plotted. Superseded by |
model |
A model fit by |
width |
The width of the mean line(s) to be plotted for group models. Note that factors are plotted 1 unit apart, so values larger than 1 will overlap into other groups. |
... |
Arguments passed on to the respective |
A gg
object
# basic examples
gf_model_old(Thumb ~ NULL, data = Fingers)
gf_model_old(Thumb ~ Height, data = Fingers)
gf_model_old(Thumb ~ RaceEthnic, data = Fingers)
# specifying the model using a fitted model
model <- lm(Thumb ~ Height, data = Fingers)
gf_model_old(model)
# chaining on to previous plots
gf_point(Thumb ~ Height, data = Fingers) %>%
gf_model_old()
gf_point(Thumb ~ Height, data = Fingers) %>%
gf_model_old() %>%
gf_model_old(Thumb ~ NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.