rlapply: Recursive List Apply

Description Usage Arguments Value Author(s) Examples

Description

Recursively apply function f to a list object containing, at some level, objects of a class appearing in classes. This is a simpler alternative to the base R function rapply.

Usage

1
rlapply(object, f, classes="ANY", ...)

Arguments

object, f, classes

as equivalent arguments to rapply.

...

further arguments to f.

Value

A list with the same structure as object.

Author(s)

Daniel Dvorkin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
set.seed(123)
x <- lapply(2:3, function(D)
        lapply(c(10, 20), function(N)
            matrix(rnorm(N*D), ncol=D)))
rlapply(x, dim, "matrix")
# [[1]]
# [[1]][[1]]
# [1] 10  2
# 
# [[1]][[2]]
# [1] 20  2
# 
# 
# [[2]]
# [[2]][[1]]
# [1] 10  3
# 
# [[2]][[2]]
# [1] 20  3

lcmix documentation built on May 2, 2019, 6:49 p.m.