is.recursive

0th

Percentile

Is an Object Atomic or Recursive?

is.atomic returns TRUE if x is of an atomic type (or NULL) and FALSE otherwise.

is.recursive returns TRUE if x has a recursive (list-like) structure and FALSE otherwise.

Keywords
classes, programming
Usage
is.atomic(x) is.recursive(x)
Arguments
x
object to be tested.
Details

is.atomic is true for the atomic types ("logical", "integer", "numeric", "complex", "character" and "raw") and NULL.

Most types of objects are regarded as recursive. Exceptions are the atomic types, NULL, symbols (as given by as.name), S4 objects with slots, external pointers, and---rarely visible from R---weak references and byte code, see typeof.

It is common to call the atomic types ‘atomic vectors’, but note that is.vector imposes further restrictions: an object can be atomic but not a vector (in that sense).

These are primitive functions.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

is.list, is.language, etc, and the demo("is.things").

Aliases
  • is.atomic
  • is.recursive
Examples
library(base) require(stats) is.a.r <- function(x) c(is.atomic(x), is.recursive(x)) is.a.r(c(a = 1, b = 3)) # TRUE FALSE is.a.r(list()) # FALSE TRUE - a list is a list is.a.r(list(2)) # FALSE TRUE is.a.r(lm) # FALSE TRUE is.a.r(y ~ x) # FALSE TRUE is.a.r(expression(x+1)) # FALSE TRUE is.a.r(quote(exp)) # FALSE FALSE
Documentation reproduced from package base, version 3.3.0, License: Part of R 3.3.0

Community examples

Looks like there are no examples yet.