Learn R Programming

rje (version 1.12.1)

greaterThan: Comparing numerical values

Description

Just a wrapper for comparing numerical values, for use with quicksort.

Usage

greaterThan(x, y)

Value

An integer vector.

Arguments

x

A numeric vector.

y

A numeric vector.

Author

Robin Evans

Details

Just returns -1 if x is less than y, 1 if x is greater, and 0 if they are equal (according to ==). The vectors wrap as usual if they are of different lengths.

See Also

`<` for traditional Boolean operator.

Examples

Run this code

greaterThan(4,6)

# Use in sorting algorithm.
quickSort(c(5,2,9,7,6), f=greaterThan)
order(c(5,2,9,7,6))

Run the code above in your browser using DataLab