Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extreme

Extrema (Maxima and Minima)


Description

We provide S3 methods for min and max for big rationals (bigq) and big integers (biqz); consequently, range() works as well.

Similarly, S4 methods are provided for which.min() and which.max().

Usage

## S3 method for class 'bigz'
max(..., na.rm=FALSE)
## S3 method for class 'bigq'
max(..., na.rm=FALSE)
## S3 method for class 'bigz'
min(..., na.rm=FALSE)
## S3 method for class 'bigq'
min(..., na.rm=FALSE)

## S4 method for signature 'bigz'
which.min(x)


## S4 method for signature 'bigq'
which.max(x)

Arguments

x

a “big integer” (bigz) or “big rational” (bigq) vector.

...

numeric arguments

na.rm

a logical indicating whether missing values should be removed.

Value

an object of class "bigz" or "bigq".

Author(s)

Antoine Lucas

See Also

max etc in base.

Examples

x <- as.bigz(1:10)
 max(x)
 min(x)
 range(x) # works correctly via default method
 x <- x[c(7:10,6:3,1:2)]
 which.min(x) ## 9
 which.max(x) ## 4

 Q <- as.bigq(1:10, 3)
 max(Q)
 min(Q)
 (Q <- Q[c(6:3, 7:10,1:2)])
 stopifnot(which.min(Q) == which.min(asNumeric(Q)),
           which.max(Q) == which.max(asNumeric(Q)))

stopifnot(range(x) == c(1,10), 3*range(Q) == c(1,10))

gmp

Multiple Precision Arithmetic

v0.6-2
GPL (>= 2)
Authors
Antoine Lucas, Immanuel Scholz, Rainer Boehme <rb-gmp@reflex-studio.de>, Sylvain Jasson <Sylvain.Jasson@inrae.fr>, Martin Maechler <maechler@stat.math.ethz.ch>
Initial release
2021-01-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.