R/array-class.R

Defines functions detectFronts.array

Documented in detectFronts.array

#' @rdname detectFronts
#' @method detectFronts array
#' @export
detectFronts.array <- function(x, method = "BelkinOReilly2009",
                               intermediate = FALSE, ...){

  # Check arguments
  checkArgs_df_array(x = x)

  output <- lapply(X = seq(dim(x)[3]),
                   FUN = function(i, ...) detectFronts(x = x[,,i], ...),
                   method = method, intermediate = intermediate,
                   checkPrevs = FALSE, ...)

  if(isTRUE(intermediate)){
    index <- names(output[[1]])
    output <- lapply(X = seq_along(index),
                     FUN = function(x) abind(lapply(output, "[[", x), along = 3))

    names(output) <- index
  }else{
    output <- abind(output, along = 3)

    dimnames(output) <- dimnames(x)
  }

  output
}

Try the grec package in your browser

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

grec documentation built on May 2, 2023, 9:11 a.m.