Skip to contents

This man page documents various base array operations that are supported by NaArray derivatives, and that didn't belong to any of the groups of operations documented in the other man pages of the SparseArray package.

Usage

# --- unary isometric array transformations ---

# S4 method for class 'NaArray'
is.nan(x)

# S4 method for class 'NaArray'
is.infinite(x)

# --- N-ary isometric array transformations ---

# COMING SOON...

Arguments

x

An NaArray object.

Details

More operations will be added in the future.

Value

is.nan() and is.infinite() return a SparseArray object of type() "logical" and same dimensions as the input object.

See also

Examples

a <- array(c(NA, 2.77, NaN, Inf, NA, -Inf), dim=5:3)
naa <- NaArray(a)  # NaArray object
naa
#> <5 x 4 x 3 NaArray> of type "double" [nnacount=40 (67%)]:
#> ,,1
#>      [,1] [,2] [,3] [,4]
#> [1,]   NA -Inf   NA  Inf
#> [2,] 2.77   NA -Inf   NA
#> [3,]  NaN 2.77   NA -Inf
#> [4,]  Inf  NaN 2.77   NA
#> [5,]   NA  Inf  NaN 2.77
#> 
#> ,,2
#>      [,1] [,2] [,3] [,4]
#> [1,]  NaN 2.77   NA -Inf
#> [2,]  Inf  NaN 2.77   NA
#> [3,]   NA  Inf  NaN 2.77
#> [4,] -Inf   NA  Inf  NaN
#> [5,]   NA -Inf   NA  Inf
#> 
#> ,,3
#>      [,1] [,2] [,3] [,4]
#> [1,]   NA  Inf  NaN 2.77
#> [2,] -Inf   NA  Inf  NaN
#> [3,]   NA -Inf   NA  Inf
#> [4,] 2.77   NA -Inf   NA
#> [5,]  NaN 2.77   NA -Inf
#> 

is.nan(naa)            # SparseArray object of type "logical"
#> <5 x 4 x 3 SparseArray> of type "logical" [nzcount=10 (17%)]:
#> ,,1
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE FALSE
#> [3,]  TRUE FALSE FALSE FALSE
#> [4,] FALSE  TRUE FALSE FALSE
#> [5,] FALSE FALSE  TRUE FALSE
#> 
#> ,,2
#>       [,1]  [,2]  [,3]  [,4]
#> [1,]  TRUE FALSE FALSE FALSE
#> [2,] FALSE  TRUE FALSE FALSE
#> [3,] FALSE FALSE  TRUE FALSE
#> [4,] FALSE FALSE FALSE  TRUE
#> [5,] FALSE FALSE FALSE FALSE
#> 
#> ,,3
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE FALSE  TRUE FALSE
#> [2,] FALSE FALSE FALSE  TRUE
#> [3,] FALSE FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE FALSE
#> [5,]  TRUE FALSE FALSE FALSE
#> 
is.infinite(naa)       # SparseArray object of type "logical"
#> <5 x 4 x 3 SparseArray> of type "logical" [nzcount=20 (33%)]:
#> ,,1
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE  TRUE FALSE  TRUE
#> [2,] FALSE FALSE  TRUE FALSE
#> [3,] FALSE FALSE FALSE  TRUE
#> [4,]  TRUE FALSE FALSE FALSE
#> [5,] FALSE  TRUE FALSE FALSE
#> 
#> ,,2
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE FALSE FALSE  TRUE
#> [2,]  TRUE FALSE FALSE FALSE
#> [3,] FALSE  TRUE FALSE FALSE
#> [4,]  TRUE FALSE  TRUE FALSE
#> [5,] FALSE  TRUE FALSE  TRUE
#> 
#> ,,3
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE  TRUE FALSE FALSE
#> [2,]  TRUE FALSE  TRUE FALSE
#> [3,] FALSE  TRUE FALSE  TRUE
#> [4,] FALSE FALSE  TRUE FALSE
#> [5,] FALSE FALSE FALSE  TRUE
#> 

## Sanity checks:
res <- is.nan(naa)
stopifnot(is(res, "SparseArray"), type(res) == "logical",
          identical(as.array(res), is.nan(a)))
res <- is.infinite(naa)
stopifnot(is(res, "SparseArray"), type(res) == "logical",
          identical(as.array(res), is.infinite(a)))