R/rep.r

Defines functions rrep crep rep

Documented in crep rep rrep

#' Repeats an array along an arbitrary axis
#'
#' @param x      An array object
#' @param n      Integer, how often to repeat
#' @param along  Along which axis to repeat (default: 1)
#' @return       An array that is repeated `n` times on axis `along`
#' @export
rep = function(x, n, along=1) {
    xl = base::rep(list(x), n)
    bind(xl, along=along)
}

#' @rdname rep
#' @export
crep = function(x, n) rep(x, n, along=2)

#' @rdname rep
#' @export
rrep = function(x, n) rep(x, n, along=1)

Try the narray package in your browser

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

narray documentation built on Oct. 2, 2022, 5:08 p.m.