Apply a function to components of an object

DESCRIPTION:

Returns a list which is the result of a function applied to slots, list elements, and attributes of an object.

USAGE:

componentsApply(X, FUN, ...) 

REQUIRED ARGUMENTS:

X
Any object.
FUN
A function.

OPTIONAL ARGUMENTS:

...
Additional arguments to FUN.

VALUE:

A list, whose elements are the values of calls to FUN, for slots, list elements, and attributes of X. There may be duplicates, e.g. for a matrix the dim attribute and .Dim slot are the same.

DETAILS:

This function does not descend recursive objects, such as functions and expressions.

Related functions include recursiveApply , which operates recursively, and lapply , which handles only list elements.

SEE ALSO:

, . This is used in and .

EXAMPLES:

# Determine whether an object or any of its components 
# (recursively) inherit from class "miVariable" 
tempf <- function(x) { 
  inherits(x, "miVariable") || 
  any(unlist(componentsApply(x, tempf))) 
} 
tempf(cholesterolImpExample)