reducer {plotscaper}R Documentation

Create a reducer

Description

Constructs a reducer that can be used to show alternative summaries in a plotscaper plot.

Usage

reducer(initialfn = NULL, reducefn = NULL, name = NULL)

Arguments

initialfn

An JavaScript initializing function

reducefn

A JavaScript reducer function specified

name

A name for the reducer (a string)

Details

reducefn and initialfn should be strings interpretable as JavaScript functions. Further:

Value

A reducer (which is really just a list with some additional formatting)

Examples

r <- reducer(initialfn = "() => 0",
             reducefn = "(x, y) => Math.max(x, y)",
             name = "max")
create_schema(mtcars) |>
  add_barplot(c("cyl", "mpg"), options = list(reducer = r))


[Package plotscaper version 0.2.5 Index]