custom_func_aggregator {shinyHugePlot}R Documentation

Aggregation using a user-defined function.

Description

Arbitrary function can be applied using this aggregation class.

Format

An R6::R6Class object

Super class

shinyHugePlot::aggregator -> custom_func_aggregator

Methods

Public methods

Inherited methods

Method new()

Constructor of the Aggregator.

Usage
custom_func_aggregator$new(
  ...,
  aggregation_func,
  interleave_gaps,
  coef_gap,
  NA_position,
  accepted_datatype
)
Arguments
aggregation_func

Function. User-defined function to aggregate data, of which arguments are x, y and n_out.

interleave_gaps, coef_gap, NA_position, accepted_datatype, ...

Arguments pass to the constructor of aggregator object.


Method set_aggregation_func()

Set a function to aggregate the data

Usage
custom_func_aggregator$set_aggregation_func(aggregation_func)
Arguments
aggregation_func

Function. User-defined function to aggregate data, of which arguments are x, y and n_out.


Method clone()

The objects of this class are cloneable with this method.

Usage
custom_func_aggregator$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

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")

[Package shinyHugePlot version 0.2.6 Index]