tests/testthat/helper-cumulative.R

cumulative_reference <- function(x, axis, f) {
  dimensions <- dim(x)
  axes <- c(axis, setdiff(seq_along(dimensions), axis))

  out <- apply(x, axes[-1L], \(line) Reduce(f, line, accumulate = TRUE))
  out <- array(out, dimensions[axes])
  out <- aperm(out, order(axes))

  dimnames(out) <- dimnames(x)
  out
}

Try the rray package in your browser

Any scripts or data that you put into this service are public.

rray documentation built on Nov. 17, 2026, 5:07 p.m.