fig_smooth: Smooth

Description Usage Arguments Details Examples

View source: R/figures.R

Description

Add a smooth(ing) figure to the chart.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fig_smooth(
  g,
  ...,
  method = c("linear", "gaussian", "cosine", "epanechnikov", "quartic", "triangular",
    "tricube", "triweight", "uniform", "polynomial", "logarithmic", "boxcar", "power",
    "exponential"),
  band_width = 1,
  sync = TRUE,
  data = NULL,
  inherit_asp = TRUE
)

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

...

Options to pass to the figure, including asp(), and adjust(), active(), selected(), and config(), other key value pairs of are passed to style.

method

Smoothing method to use.

band_width

Step size for Silverman's algorithm.

sync

Whether to sync the axis data (align) with that used in other figures, set to FALSE to not sync or set to a character string to use as name of sync group.

data

A dataset (data.frame or tibble) to use to draw the figure.

inherit_asp

Whether to inherit the aspects paseed to g2() initialisation function.

Details

Requires the x and y aspects.

This is a convenience function for a quick smoothing, see the online documentation to see how to use your own model for more control.

Examples

1
2
3
4
5
6
7
g2(cars, asp(speed, dist)) %>%
  fig_point() %>%
  fig_smooth(method = "gaussian")

g2(iris, asp(Sepal.Width, Sepal.Length, color = Species)) %>%
  fig_point() %>%
  fig_smooth()

devOpifex/g2r documentation built on Jan. 16, 2022, 12:36 a.m.