R/slice.R

Defines functions `slice`

`slice` <-
function(x, MARGIN, n)
{
  result <- x[slice.index(x, MARGIN) == n]
  if(length(result) == prod(dim(x)[-MARGIN]))
  {
    dim(result) <- dim(x)[-MARGIN]
    dimnames(result) <- dimnames(x)[-MARGIN]
  }
  return(result)
}

Try the cmrutils package in your browser

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

cmrutils documentation built on May 1, 2019, 7:59 p.m.