Filters the data that satisfy a condition.

mask(x, ...)

# S3 method for default
mask(x, tol.mask = 0, ...)

# S3 method for data.grid
mask(x, mask = NULL, window = NULL, set.NA = FALSE, warn = FALSE, ...)

# S3 method for bin.den
mask(
  x,
  mask = mask.default(x$binw, npsp.tolerance(2)),
  window = NULL,
  set.NA = FALSE,
  warn = TRUE,
  ...
)

# S3 method for bin.data
mask(
  x,
  mask = NULL,
  window = NULL,
  set.NA = FALSE,
  warn = FALSE,
  filter.lp = TRUE,
  ...
)

# S3 method for locpol.bin
mask(
  x,
  mask = mask.default(x$binw, npsp.tolerance(2)),
  window = NULL,
  set.NA = FALSE,
  warn = TRUE,
  filter.lp = TRUE,
  ...
)

Arguments

x

object used to select a method (binned data, ...).

...

further arguments passed to or from other methods

tol.mask

tolerance.

mask

logical; vector (or array) indicating the selected values (not masked).

window

spatial window (values outside this window will be masked), currently an sp-object of class extending SpatialPolygons.

set.NA

logical; If TRUE, the values corresponding to masked cells are set to NA.

warn

logical; If TRUE a warning message is generated when original data is masked.

filter.lp

logical; If TRUE, masked nodes will be leaved out in local polynomial estimation.

Value

mask.default returns the logical vector x > tol.mask.

mask.bin.den, mask.bin.data and mask.locpol.bin

return an object of the same class as x with the additional component $mask

and optionally $window.

Examples

mask(1:10, 5)
#>  [1] FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE
bin <- binning(aquifer[,1:2], aquifer$head, nbin = c(41,41), set.NA = TRUE)
str(mask(bin, mask(bin$binw), warn = TRUE))
#> List of 5
#>  $ biny: num [1:41, 1:41] NA NA NA NA NA NA 3510 3510 NA NA ...
#>  $ binw: num [1:41, 1:41] -1 -1 -1 -1 -1 ...
#>  $ grid:List of 6
#>   ..$ nd      : int 2
#>   ..$ n       : int [1:2] 41 41
#>   ..$ min     : num [1:2] -145.24 9.41
#>   ..$ max     : num [1:2] 113 185
#>   ..$ lag     : num [1:2] 6.45 4.38
#>   ..$ dimnames: chr [1:2] "lon" "lat"
#>   ..- attr(*, "class")= chr "grid.par"
#>  $ data:List of 3
#>   ..$ x  : num [1:85, 1:2] 42.78 -27.4 -1.16 -18.62 96.47 ...
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:85] "1" "2" "3" "4" ...
#>   .. .. ..$ : chr [1:2] "lon" "lat"
#>   ..$ y  : num [1:85] 1464 2553 2158 2455 1756 ...
#>   ..$ med: num 2002
#>  $ mask: logi [1:1681] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>  - attr(*, "class")= chr [1:3] "bin.data" "bin.den" "data.grid"
str(mask(bin, mask(bin$binw, 1)))
#> List of 6
#>  $ biny  : num [1:41, 1:41] NA NA NA NA NA NA 3510 3510 NA NA ...
#>  $ binw  : num [1:41, 1:41] -1 -1 -1 -1 -1 ...
#>  $ grid  :List of 6
#>   ..$ nd      : int 2
#>   ..$ n       : int [1:2] 41 41
#>   ..$ min     : num [1:2] -145.24 9.41
#>   ..$ max     : num [1:2] 113 185
#>   ..$ lag     : num [1:2] 6.45 4.38
#>   ..$ dimnames: chr [1:2] "lon" "lat"
#>   ..- attr(*, "class")= chr "grid.par"
#>  $ data  :List of 3
#>   ..$ x  : num [1:85, 1:2] 42.78 -27.4 -1.16 -18.62 96.47 ...
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:85] "1" "2" "3" "4" ...
#>   .. .. ..$ : chr [1:2] "lon" "lat"
#>   ..$ y  : num [1:85] 1464 2553 2158 2455 1756 ...
#>   ..$ med: num 2002
#>  $ mask  : logi [1:1681] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>  $ nomask: int [1:252] 7 8 19 20 35 36 48 49 60 61 ...
#>  - attr(*, "class")= chr [1:3] "bin.data" "bin.den" "data.grid"