Nothing
#' Reverse a sorting function
#'
#' Transform a function (typically used in \code{\link{sort_by}}), so that its
#' ouput can be sorted in descending order.
#'
#' @param f a function to modify.
#'
#' @return A function returning a numeric vector which, if passed to
#' \code{\link{order}}, will be used to sort some data.
#'
#' @examples
#' desc_abs <- descending(abs)
#'
#' x <- -2:1
#' order(abs(x))
#' order(desc_abs(x))
#' @export
descending <- function(f) {
force(f) # to avoid lazy evaluation in a loop
if (requireNamespace("purrr", quietly = TRUE)) {
f <- purrr::as_mapper(f)
}
function(x) -xtfrm(f(x))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.