Learn R Programming

spatstat.utils (version 3.1-2)

RelevantNA: Missing Value, Zero-length Vector, or Zero Value of the Appropriate Type

Description

Given any data x, these functions return the missing value NA, the empty vector, or the equivalent of the number 0, with the same type as x.

Usage

RelevantZero(x)
RelevantNA(x)
RelevantEmpty(x)

isRelevantZero(x)

Value

RelevantZero and RelevantNA return a single value of the same type as x.

RelevantEmpty returns a zero-length vector of the same type as x.

isRelevantZero returns a single logical value.

Arguments

x

Data of any type.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

Details

In the R system, missing values may have different types. For example, if an entry is missing from a numeric vector, it is a missing numeric value, not a missing logical value, and R distinguishes between these two types of missing values.

The function RelevantNA returns a missing value of the same type as the input x (as defined by typeof). Thus, RelevantNA(3.2) returns a missing numeric value and RelevantNA(TRUE) returns a missing logical value.

RelevantEmpty(x) returns a vector of length zero which has the same type as x. Thus, RelevantEmpty(TRUE) is equivalent to logical(0).

RelevantZero(x) returns a single value, of the same type as x, that is equivalent to the number zero. For example, RelevantZero(TRUE) returns FALSE.

The function isRelevantZero tests whether x is a single zero value, by testing whether x is identical to RelevantZero(x).

See Also

Examples

Run this code
   RelevantZero(42)
   RelevantZero(TRUE)
   RelevantZero("hello world")

   RelevantNA(1:3)
   typeof(RelevantNA(1:3))
   typeof(RelevantNA("hello world"))

Run the code above in your browser using DataLab