Learn R Programming

collapse (version 1.2.1)

is.regular-is.unlistable: Regular Objects and Unlistable Lists

Description

A regular R object is an R object that is either atomic or a list - checked with is.regular. A (nested) list composed of regular objects at each level is unlistable - checked with is.unlistable.

Usage

is.regular(x)
is.unlistable(l)

Arguments

x

a R object.

l

a list.

Value

logical(1) - TRUE or FALSE.

Details

is.regular is simply defined as is.atomic(x) || is.list(x). is.unlistable is defined as all(unlist(rapply2d(l, is.regular), use.names = FALSE)). It could of course also be defined as all(rapply(l, is.atomic)), but the above is a lot more efficient if l contains data.frame's.

See Also

ldepth, has_elem, List Processing, Collapse Overview

Examples

Run this code
# NOT RUN {
is.regular(list(1,2))
is.regular(2)
is.regular(a ~ c)
l <- list(1, 2, list(3, 4, "b", FALSE))
is.regular(l)
is.unlistable(l)
l <- list(1, 2, list(3, 4, "b", FALSE, e ~ b))
is.regular(l)
is.unlistable(l)

# }

Run the code above in your browser using DataLab