Description Usage Arguments Details Value Examples
View source: R/viz_fitted_line.R
This function is mostly useful in an educational setting. Can only be used with trained workflow objects with 1 numeric predictor variable.
1 2 3 4 5 6 7 8 | viz_fitted_line(
x,
new_data,
resolution = 100,
expand = 0.1,
color = "blue",
size = 1
)
|
x |
trained 'workflows::workflow' object. |
new_data |
A data frame or tibble for whom the preprocessing will be applied. |
resolution |
Number of squared in grid. Defaults to 100. |
expand |
Expansion rate. Defaults to 0.1. This means that the width of the plotting area is 10 percent wider then the data. |
color |
Character, color of the fitted line. Passed to 'geom_line()'. Defaults to '"blue"'. |
size |
Numeric, size of the fitted line. Passed to 'geom_line()'. Defaults to '1'. |
The chart have been minimally modified to allow for easier styling.
'ggplot2::ggplot' object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | library(parsnip)
library(workflows)
lm_spec <- linear_reg() %>%
set_mode("regression") %>%
set_engine("lm")
lm_fit <- workflow() %>%
add_formula(mpg ~ disp) %>%
add_model(lm_spec) %>%
fit(mtcars)
viz_fitted_line(lm_fit, mtcars)
viz_fitted_line(lm_fit, mtcars, expand = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.