Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

inside.boxx

Test Whether Points Are Inside A Multidimensional Box


Description

Test whether points lie inside or outside a given multidimensional box.

Usage

inside.boxx(..., w)

Arguments

...

Coordinates of points to be tested. One vector for each dimension (all of same length). (Alternatively, a single point pattern object of class "ppx" or its coordinates as a matrix, data.frame, or "hyperframe")

w

A window. This should be an object of class boxx, or can be given in any format acceptable to as.boxx().

Details

This function tests whether each of the provided points lies inside or outside the window w and returns TRUE if it is inside.

The boundary of the window is treated as being inside.

Normally each argument provided (except w) must be numeric vectors of equal length (length zero is allowed) containing the coordinates of points. Alternatively a single point pattern (object of class "ppx") can be given; then the coordinates of the point pattern are extracted. A single matrix, data.frame, or "hyperframe") with the coordinates is also accepted.

Value

Logical vector whose ith entry is TRUE if the corresponding point is inside w.

Author(s)

and Ege Rubak rubak@math.aau.dk

See Also

Examples

# 3D box with side [0,2]
  w <- boxx(c(0,2), c(0,2), c(0,2))

  # Random points in box with side [-1,3]
  x <- runif(30, min=-1, max=3)
  y <- runif(30, min=-1, max=3)
  z <- runif(30, min=-1, max=3)

  # Points falling in smaller box
  ok <- inside.boxx(x, y, z, w=w)

  # Same using a point pattern as argument:
  X <- ppx(data = cbind(x, y, z), domain = boxx(c(0,3), c(0,3), c(0,3)))
  ok2 <- inside.boxx(X, w=w)

  # Same using the coordinates given as data.frame/matrix/hyperframe
  coords_mat <- cbind(x,y,z)
  ok_mat <- inside.boxx(coords_mat, w=w)
  coords_df <- data.frame(x,y,z)
  ok_df <- inside.boxx(coords_mat, w=w)
  coords_hyper <- hyperframe(x,y,z)
  ok_hyper <- inside.boxx(coords_mat, w=w)

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.