loapply {ooplah}R Documentation

Specialised lapply for objects

Description

Specialised lapply functions for R6 or other OOP classes. This is simply a wrapper that detects if FUN is a function, in which case lapply is used as usual, or a string, in which case the given field/method is returned as a list.

Usage

loapply(X, FUN, ...)

Arguments

X, ...

See lapply

FUN

Either a function to apply to each element of X, as in lapply or the field/method name of an OOP object (see examples)

Examples

## lapply as usual
loapply(c(1, 2, 3), identity)

## For R6 objects
objs <- list(ooplah$new(), ooplah$new())
# Public field
loapply(objs, "oop")
# Public method
loapply(objs, "hello")

[Package ooplah version 0.2.0 Index]