all-methods: "Matrix" Methods for Functions all() and any()

Description Methods Examples

Description

The basic R functions all and any now have methods for Matrix objects and should behave as for matrix ones.

Methods

all

signature(x = "Matrix", ..., na.rm = FALSE): ...

any

signature(x = "Matrix", ..., na.rm = FALSE): ...

all

signature(x = "ldenseMatrix", ..., na.rm = FALSE): ...

all

signature(x = "lsparseMatrix", ..., na.rm = FALSE): ...

Examples

1
2
3
4
5
6
7
M <- Matrix(1:12 +0, 3,4)
all(M >= 1) # TRUE
any(M < 0 ) # FALSE
MN <- M; MN[2,3] <- NA; MN
all(MN >= 0) # NA
any(MN <  0) # NA
any(MN <  0, na.rm = TRUE) # -> FALSE

Matrix documentation built on June 11, 2021, 3 p.m.