R/head.R

Defines functions tail.index0 head.index0

Documented in head.index0 tail.index0

#' Return the First or Last Parts of a Zero-Indexed Object
#' 
#' Works like [utils::head()] and [utils::tail()].
#' 
#' Just because an object is zero-indexed, doesn't mean that the definition of,
#' for example, "the first 5 elements" or "the last two elements" has changed.
#' Thus we add methods `head()` and `tail()` to ensure they behave as normal.
#' 
#' @param x An `index0` object
#' @param ... Other arguments, passed to generic function
#' 
#' @return An `index0` object
#' 
#' @importFrom utils head tail
#' @rdname head
#' @export
head.index0 <- function(x, ...) {
  x <- as.index1(x)
  as.index0(NextMethod())
}

#' @rdname head
#' @export
tail.index0 <- function(x, ...) {
  x <- as.index1(x)
  as.index0(NextMethod())
}

Try the index0 package in your browser

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

index0 documentation built on Dec. 3, 2021, 9:06 a.m.