check.range {spatstat.utils} | R Documentation |
These simple functions handle an interval or range of numerical
values. check.range(r)
checks whether r
specifies a
range of values, that is, whether r
is a vector of length 2
with r[1] <= r[2]
. intersect.ranges(r, s)
finds the intersection
of two ranges r
and s
. inside.range(x, r)
returns
a logical vector containing TRUE
if the corresponding entry of
x
falls inside the range r
, and FALSE
if it does
not. check.in.range(x, r)
checks whether a single number
x
falls inside the specified range r
.
Finally prange(r)
produces a character string that represents
the range r
.
check.range(r, fatal = TRUE) check.in.range(x, r, fatal = TRUE) inside.range(x, r) intersect.ranges(r, s, fatal = TRUE) prange(r)
r |
A numeric vector of length 2 specifying the endpoints of a range of values. |
x |
Numeric vector of data. |
s |
A numeric vector of length 2 specifying the endpoints of a range of values. |
fatal |
Logical value indicating whether to stop with an error message if the data do not pass the check. |
check.range
checks whether r
specifies a
range of values, that is, whether r
is a vector of length 2
with r[1] <= r[2]
. If so, the result is TRUE
. If not,
then if fatal=TRUE
, an error occurs, while if
fatal=FALSE
the result is FALSE
.
intersect.ranges(r, s)
finds the intersection
of two ranges r
and s
. If the intersection is non-empty,
the result is a numeric vector of length 2. If the intersection is empty,
then if fatal=TRUE
, an error occurs, while if
fatal=FALSE
the result is NULL
.
inside.range(x, r)
returns
a logical vector containing TRUE
if the corresponding entry of
x
falls inside the range r
, and FALSE
if it does
not.
check.in.range(x, r)
checks whether a single number
x
falls inside the specified range r
.
If so, the result is TRUE
. If not, then if fatal=TRUE
,
an error occurs, while if
fatal=FALSE
the result is FALSE
.
Finally prange(r)
produces a character string that represents
the range r
.
The result of check.range
, check.in.range
and inside.range
, is
a logical value or logical vector. The result of
intersect.ranges
is a numerical vector of length 2, or NULL
.
The result of prange
is a character string.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au
rr <- c(0, 2) ss <- c(1, 3) x <- seq(0.5, 3.5, by=1) check.range(rr) check.range(42, fatal=FALSE) inside.range(x, rr) intersect.ranges(rr, ss) prange(rr)