custom_func_aggregator | R Documentation |
Arbitrary function can be applied using this aggregation class.
An R6::R6Class
object
shinyHugePlot::aggregator
-> custom_func_aggregator
new()
Constructor of the Aggregator.
custom_func_aggregator$new( ..., aggregation_func, interleave_gaps, coef_gap, NA_position )
aggregation_func
Function.
User-defined function to aggregate data,
of which arguments are x
, y
and n_out
.
interleave_gaps, coef_gap, NA_position, ...
Arguments pass to the constructor of aggregator
object.
set_aggregation_func()
Set a function to aggregate the data
custom_func_aggregator$set_aggregation_func(aggregation_func)
aggregation_func
Function.
User-defined function to aggregate data,
of which arguments are x
, y
and n_out
.
clone()
The objects of this class are cloneable with this method.
custom_func_aggregator$clone(deep = FALSE)
deep
Whether to make a deep clone.
custom_agg_func <- function(x, y, n_out) {
bin_width <- floor(length(x)/n_out)
x_idx <- seq(floor(bin_width / 2), bin_width * n_out, bin_width)
y_mat <- y[1:(bin_width * n_out)] %>%
matrix(nrow = bin_width)
y_agg <- apply(y_mat, 2, quantile, probs = 0.25)
return(list(x = x[x_idx], y = y_agg))
}
data(noise_fluct)
agg <- custom_func_aggregator$new(
aggregation_func = custom_agg_func, interleave_gaps = TRUE
)
d_agg <- agg$aggregate(
x = noise_fluct$time, y = noise_fluct$f500, n_out = 1000
)
plotly::plot_ly(x = d_agg$x, y = d_agg$y, type = "scatter", mode = "lines")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.