Learn R Programming

Matrix (version 1.2-1)

is.na-methods: is.na(), is.{in}finite() Methods for 'Matrix' Objects

Description

Methods for function is.na(), is.finite(), and is.infinite() for all Matrices (objects extending the Matrix class):

[object Object],[object Object]

Usage

## S3 method for class 'sparseMatrix':
is.na(x)
## S3 method for class 'dsparseMatrix':
is.finite(x)
## S3 method for class 'ddenseMatrix':
is.infinite(x)
## ...
## and for other classes

## S3 method for class 'xMatrix': anyNA(x) ## S3 method for class 'nsparseMatrix': anyNA(x) ## S3 method for class 'sparseVector': anyNA(x) ## S3 method for class 'nsparseVector': anyNA(x)

Arguments

x
sparse or dense matrix or sparse vector (here; any Robject in general).

See Also

NA, is.na; is.finite, is.infinite; nMatrix, denseMatrix, sparseMatrix.

The sparseVector class.

Examples

Run this code
M <- Matrix(1:6, nrow=4, ncol=3,
       dimnames = list(c("a", "b", "c", "d"), c("A", "B", "C")))
stopifnot(all(!is.na(M)))
M[2:3,2] <- NA
is.na(M)
if(exists("anyNA", mode="function"))
anyNA(M)

A <- spMatrix(10,20, i = c(1,3:8),
                     j = c(2,9,6:10),
                     x = 7 * (1:7))
stopifnot(all(!is.na(A)))A[2,3] <- A[1,2] <- A[5, 5:9] <- NA
inA <- is.na(A)
stopifnot(sum(inA) == 1+1+5)
if(exists("anyNA", mode="function"))
stopifnot(anyNA(M), anyNA(A))

Run the code above in your browser using DataLab