is.atomic
Test for Atomic or Recursive Objects

Description

Returns a logical value that depends on the mode of the input.

Usage

is.atomic(x) 
is.language(x) 
is.recursive(x)

Arguments

x any object.

Details

is.recursive and is.atomic are not quite complementary, but they do not overlap. For example, objects of mode name are neither recursive nor atomic, and both objects return FALSE for an object with slots.
Value
is.atomicreturns TRUE if the mode of x is numeric, logical, character, complex, raw, or null. For example, an object of mode list is not atomic, while a matrix of mode numeric is atomic.
is.languagereturns TRUE if x is an object that is part of the language (that is, the value of a call to parse or an object that has one of the special modes used by the engine's parser such as call, if, or expression).
is.recursivereturns TRUE if the mode of x indicates that x is a recursive object; that is, it is an object that can contain other objects as elements: most commonly list, but also expression, graphics, and a number of modes used in manipulating the language. However, is.recursive returns FALSE for objects with slots. (Use length(getSlots(x)) to determine if an object has slots.)
References
Becker, R. A., Chambers, J. M., and Wilks, A. R. 1988. The New S Language. Pacific Grove, CA: Wadsworth & Brooks/Cole Advanced Books and Software.
See Also
vector, mode
Examples
x <- matrix(1:12, 4)
is.atomic(x)    # returns TRUE 
is.language(x)  # returns FALSE
is.recursive(x) # returns FALSE

x <- list(a=1, b=list(c=2, d=3)) is.atomic(x) # returns FALSE is.language(x) # returns FALSE is.recursive(x) # returns TRUE

x <- as.name("foo") is.atomic(x) # returns FALSE is.language(x) # returns TRUE is.recursive(x) # returns FALSE

x <- expression(1+x) is.atomic(x) # returns FALSE is.language(x) # returns TRUE is.recursive(x) # returns TRUE

x <- call('print', 1:3) is.atomic(x) # returns FALSE is.language(x) # returns TRUE is.recursive(x) # returns TRUE

is.atomic(NULL) # returns TRUE

Package base version 6.0.0-69
Package Index