lapplyDatasets: Lapply for generated datasets

View source: R/fitDatasets.R

lapplyDatasetsR Documentation

Lapply for generated datasets

Description

Apply function for all generated datasets.

Usage

lapplyDatasets(datasets, FUN, ..., label, POST_FUN, datasetIndices = "all")

Arguments

datasets

Datasets list to be used to generate datasets.

FUN

the function to be applied to each generated dataset. The function will be called like FUN(data, ...).

...

optional arguments to FUN.

label

optional parameter, if present, each result is added an attribute named label with the value of label.

POST_FUN

function to be applied to the result of FUN. While one could just modify FUN instead, this additional argument makes it a bit easier to combine different kinds of methods together.

datasetIndices

optional vector of dataset indices to fit, useful to try only a few datasets instead of all of them. Use "all" to process all datasets (default).

Value

list of results. The items in the resulting list will have two additional attributes: datasetIndex and proc.time. If FUN failed for an item, then the item will be the error as returned by try, i.e., it ill be of class try-error.

Author(s)

Manuel Koller

Examples

  oneWay <- generateAnovaDatasets(2, 1, 5, 4)
  lapplyDatasets(oneWay, function(data) sum(data$y))
  lapplyDatasets(oneWay, function(data) sum(data$y), POST_FUN = function(x) x^2)

robustlmm documentation built on Nov. 15, 2023, 1:07 a.m.