loapply: Specialised lapply for objects

Description Usage Arguments Examples

View source: R/vxapply.R

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

1
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

1
2
3
4
5
6
7
8
9
## 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")

ooplah documentation built on Sept. 10, 2021, 5:08 p.m.