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

apply

Apply Functions Over Matrix Margins (Rows or Columns)


Description

These are S3 methods for apply() which we re-export as S3 generic function. They “overload” the apply() function for big rationals ("bigq") and big integers ("bigz").

Usage

## S3 method for class 'bigz'
apply(X, MARGIN, FUN, ...)
## S3 method for class 'bigq'
apply(X, MARGIN, FUN, ...)

Arguments

X

a matrix of class bigz or bigq, see e.g., matrix.bigz.

MARGIN

1: apply function to rows; 2: apply function to columns

FUN

function to be applied

...

(optional) extra arguments for FUN(), as e.g., in lapply.

Value

The bigz and bigq methods return a vector of class "bigz" or "bigq", respectively.

Author(s)

Antoine Lucas

See Also

apply; lapply is used by our apply() method.

Examples

x <- as.bigz(matrix(1:12,3))
 apply(x,1,min)
 apply(x,2,max)

 x <- as.bigq(x ^ 3, d = (x + 3)^2)
 apply(x,1, min)
 apply(x,2, sum)
 ## now use the "..." to pass  na.rm=TRUE :
 x[2,3] <- NA
 apply(x,1, sum)
 apply(x,1, sum, na.rm = TRUE)

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.