Rev 86878 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/is.recursive.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2024 R Core Team% Distributed under GPL 2 or later\name{is.recursive}\alias{is.atomic}\alias{is.recursive}\title{Is an Object Atomic or Recursive?}\usage{is.atomic(x)is.recursive(x)}\description{\code{is.atomic} returns \code{TRUE} if \code{x} is of an atomic typeand \code{FALSE} otherwise.\code{is.atomic(NULL)} returns \code{FALSE} since \R version 4.4.0.\code{is.recursive} returns \code{TRUE} if \code{x} has a recursive(list-like) structure and \code{FALSE} otherwise.}\arguments{\item{x}{object to be tested.}}\details{\code{is.atomic} is true for the \link{atomic} types(\code{"logical"}, \code{"integer"}, \code{"numeric"},\code{"complex"}, \code{"character"} and \code{"raw"}).Most types of objects are regarded as recursive. Exceptions are the atomictypes, \code{NULL}, symbols (as given by \code{\link{as.name}}),\code{S4} objects with slots, external pointers, and---rarely visiblefrom \R---weak references and byte code, see \code{\link{typeof}}.It is common to call the atomic types \sQuote{atomic vectors}, butnote that \code{\link{is.vector}} imposes further restrictions: anobject can be atomic but not a vector (in that sense).These are \link{primitive} functions.}\references{\bibshow{R:Becker+Chambers+Wilks:1988}}\seealso{\code{\link{is.list}},\code{\link{is.language}}, etc,and the \code{demo("is.things")}.}\examples{require(stats)is.a.r <- function(x) c(is.atomic(x), is.recursive(x))is.a.r(c(a = 1, b = 3)) # TRUE FALSEis.a.r(list()) # FALSE TRUE - a list is a listis.a.r(list(2)) # FALSE TRUEis.a.r(lm) # FALSE TRUEis.a.r(y ~ x) # FALSE TRUEis.a.r(expression(x+1)) # FALSE TRUEis.a.r(quote(exp)) # FALSE FALSEis.a.r(NULL) # FALSE FALSE# Reproduce pre-4.4 behavior of is.atomic()is.atomicN <- function(x) is.atomic(x) || is.null(x)is.atomicN(NULL) # TRUE}\keyword{programming}\keyword{classes}