Best: Find the best value in a vector.

Description Usage Arguments Value Examples

View source: R/Best.R

Description

Best() takes a vector .x and a binary predicate function .f and returns the result of .f reduced over .x.

Usage

1
Best(.x, .f)

Arguments

.x

A vector.

.f

A binary predicate function.

Value

The best value in that vector, as determined by the binary predicate function.

Examples

1
2
3
4
5
6
# Simulate the behavior of max with numerics
Best(1:10, function(x, y) return(x > y))
# Simulate the behavior of min with numerics
Best(1:10, function(x, y) return(x < y))
# This comparison function prefers values that begin with l
Best(letters, function(x, y) return(x[1] == "l"))

paulhendricks/functools documentation built on May 24, 2019, 8:41 p.m.