R/order.R

Defines functions order.lvec order.default order

Documented in order order.default order.lvec

#' @rdname order
#' @export
order <- function(x, ...) {
  UseMethod("order")
}

#' @rdname order
#' @export
order.default <- function(x, ...) {
  base::order(x, ...)
}

#' Order a lvec
#'
#' @param x lvec to sort
#' @param ... unused.
#'
#' @return
#' Returns the order of \code{x}. Unlike the default \code{\link{order}} 
#' function in R, the sort used is not stable (e.g. in case there are multiple
#' records with the same value in \code{x}, there relative order after sorting
#' is not defined). 
#'
#' @examples
#' x <- as_lvec(rnorm(10))
#' order(x)
#'
#' @rdname order
#' @useDynLib lvec
#' @export
order.lvec <- function(x, ...) {
  if (!is_lvec(x)) stop("x should be of type lvec.")
  o <- .Call("order", x)
  structure(o, class = "lvec")
}

Try the lvec package in your browser

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

lvec documentation built on May 24, 2018, 9:04 a.m.