NaArray-Math-methods: 'Math' and 'Math2' methods for NaArray objects

NaArray-Math-methodsR Documentation

'Math' and 'Math2' methods for NaArray objects

Description

EXPERIMENTAL!!!

NaArray objects support all operations from the Math and Math2 groups with a few exceptions. See ?S4groupGeneric in the methods package for more information about the Math and Math2 group generics.

Note that Math and Math2 operations only support NaArray objects of type() "double" at the moment. NaArray objects of type() "integer" are not supported yet.

Value

A NaArray derivative of the same dimensions as the input object.

See Also

  • S4groupGeneric in the methods package.

  • NaArray objects.

  • Ordinary array objects in base R.

Examples

nam <- NaArray(dim=c(15, 6))
nam[c(2, 6, 12:17, 22:33, 55, 59:62, 90)] <-
               c(runif(22)*1e4, Inf, -Inf, NA, NaN)

log(nam)
exp(nam)
cos(nam)
lgamma(nam)

## Sanity checks:
m <- as.matrix(nam)
stopifnot(
  suppressWarnings(identical(as.matrix(log(nam)), log(m))),
  identical(as.matrix(exp(nam)), exp(m)),
  suppressWarnings(identical(as.matrix(cos(nam)), cos(m))),
  suppressWarnings(identical(as.matrix(lgamma(nam)), lgamma(m)))
)

Bioconductor/SparseArray documentation built on Nov. 14, 2024, 6:22 p.m.