check.nvector: Check For Numeric Vector With Correct Length

View source: R/utilarg.R

check.nvectorR Documentation

Check For Numeric Vector With Correct Length

Description

This is a programmer's utility function to check whether the argument is a numeric vector of the correct length.

Usage

     check.nvector(v, npoints = NULL, fatal = TRUE, things = "data points",
                   naok = FALSE, warn = FALSE, vname, oneok = FALSE)

Arguments

v

The argument to be checked.

npoints

The required length of v.

fatal

Logical value indicating whether to stop with an error message if v does not satisfy all requirements.

things

Character string describing what the entries of v should correspond to.

naok

Logical value indicating whether NA values are permitted.

warn

Logical value indicating whether to issue a warning if v does not satisfy all requirements.

vname

Character string giving the name of v to be used in messages.

oneok

Logical value indicating whether v is permitted to have length 1.

Details

This function checks whether v is a numeric vector with length equal to npoints (or length equal to 1 if oneok=TRUE), not containing any NA values (unless naok=TRUE).

If these requirements are all satisfied, the result is the logical value TRUE.

If not, then if fatal=TRUE (the default), an error occurs; if fatal=FALSE, the result is the logical value FALSE with an attribute describing the requirement that was not satisfied.

Value

A logical value indicating whether all the requirements were satisfied. If FALSE, then this value has an attribute "whinge", a character string describing the requirements that were not satisfied.

Author(s)

\adrian

.

See Also

check.anyvector, check.nmatrix, check.1.real, check.named.vector.

Examples

   z <- 1:10
   check.nvector(z, 5, fatal=FALSE)
   y <- 42
   check.nvector(y, 5, fatal=FALSE, oneok=TRUE)

spatstat.utils documentation built on Oct. 24, 2023, 9:08 a.m.