Add smoothing methods based on x and y and, optionally group aspects.

fig_smooth(g2, ..., method = "lm", data = NULL, inherit_asp = TRUE,
  name = NULL)

Arguments

g2

An object of class g2r as returned by g2r.

...

Any option, aesthetic (asp), or animation (Animation).

method

Smoothing method (function) to use, accepts either a character vector, e.g. "lm", "glm", "gam", "loess" or a function, e.g. MASS::rlm or mgcv::gam, base::lm, or base::loess.

data

A data.frame containing data to chart or a list.

inherit_asp

Whether to inherit aspects from g2r.

name

Name of figure, useful to apply functions to specific figures.

Examples

g2(cars, asp(speed, dist)) %>% fig_point() %>% fig_smooth()