applytoeachinlist: Apply a function to each member of a list, possibly splitting...

Description Usage Arguments Value

View source: R/applytoeachinlist.R

Description

Apply a function to each member of a list, possibly splitting a dataframe alongside the list (e.g. to supply newdata to every member of a list)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
applytoeachinlist(
  listobject = NULL,
  applyfun = NULL,
  applyargs = NULL,
  fallbackargs = NULL,
  nameaftersplit = NULL,
  splitalongside = NULL,
  splitalongsidename = NULL,
  splitalongsidesplitter = NULL
)

Arguments

listobject

A named list object containing elements to which the applyfun will be applied.

applyfun

The character name of a function to apply.

applyargs

A named list of arguments supplied to applyfun.

fallbackargs

A named list of arguments to try in case the primary 'applyargs' fail.

nameaftersplit

The name of the argument of applyfun that takes the settosplit dataframe after it has been split; this is commonly 'x' or 'data'

splitalongside

An optional dataframe that should be split alongside the listobject, containing the factor variable splitalongsidename. For example, if listobject is a list of regressions, then splitalongside may be a set of newdata, indexed so that predictions for each regression depend only on some subset of splitalongside

splitalongsidename

what should the splitalongside frame be called after it has been split? This is commonly something like "newdata"

splitalongsidesplitter

The name of the factor variable in settosplit, over which it should be split.

Value

This function returns a named list of results, having applied applyfun to settosplit for every level of the 'over' variable. So for example, applytoeachinlist(...)[["a"]] is the result of applyfun(listobject[["a"]]).


EcoGRAPH/clusterapply documentation built on March 8, 2021, 1:55 p.m.