reducer | R Documentation |
Constructs a reducer that can be used to show alternative summaries
in a plotscaper
plot.
reducer(initialfn = NULL, reducefn = NULL, name = NULL)
initialfn |
An JavaScript initializing function |
reducefn |
A JavaScript reducer function specified |
name |
A name for the reducer (a string) |
reducefn
and initialfn
should be strings interpretable
as JavaScript functions. Further:
initialfn
should take 0 arguments and just return some value (i.e. a thunk).
reducefn
should take two arguments previous
and next
and return a result
of the same type as previous
.
A reducer (which is really just a list
with some additional formatting)
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.