getLapplyIndex: getLapplyIndex: Access Index of List Element Within lapply()

Description Usage Value Author(s) Examples

View source: R/getLapplyIndex.R

Description

Get name/index of current list element from within FUN argument of lapply()

Usage

1

Value

Returns an integer value indicating the current index of the list passed as the X argument to lapply(). If X is named, the name of the current element will be the name of the index.

Author(s)

M.W.Rowe, mwr.stats@gmail.com

Examples

1
2
3
4
5
6
7
8
  x <- list(a=1:10, b=1:10, c=1:10)
  FUNS <- list(a=mean, b=prod, c=max)
  FUN <- function(x){
     ndx <- getLapplyIndex()
     y <- FUNS[[names(ndx)]](x)
     y
  }
  lapply(x, FUN)

mwrowe/microRutils documentation built on June 12, 2021, 2:41 p.m.