Apply a function to an object and its components, recursively.

DESCRIPTION:

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

USAGE:

recursiveApply(X, FUN, ..., skip = F) 

REQUIRED ARGUMENTS:

X
Any object.
FUN
A function.

OPTIONAL ARGUMENTS:

...
Additional arguments to FUN.
skip
logical, if TRUE then do not apply FUN to X itself. This may be used to avoid infinite loops.

VALUE:

A list, whose elements are the values of calls to FUN , for X, its slots, its list elements, and its attributes. 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 lapply , which handles only list elements, and rapply , which is similar to recursiveApply except does not allow ... arguments, and currently does not process attributes of non-list objects, skips some slots (e.g. the .Data slot of some objects), and does descend functions.

SEE ALSO:

, , .

EXAMPLES:

# Does any part of an object inherits from "miVariable"? 
any(unlist(recursiveApply(cholesterolImpExample, 
                          inherits, "miVariable"))) 
                       
# Use get for a function with an unusual name 
recursiveApply(cholesterolImpExample, get("["), 1)