lapply {MethylIT}R Documentation

Apply a function over a list-like object preserving its attributes

Description

lapply returns a list of the same length as 'x', each element of which is the result of applying FUN to the corresponding element of 'x'.

Usage

lapply(x, FUN, ...)

## Default S3 method:
lapply(x, FUN, keep.attr = FALSE, ...)

Arguments

x

A list-like or vector-like object

FUN, ...

See ?base::lapply for a description of these arguments.

keep.attr

Logic. If TRUE, then the original attributes from 'x' are preserved in the returned list. Derfaul is FALSE.

Value

Same as in ?base::lapply if keep.attr = FALSE. Otherwise same values preserving original attributes from 'x'.

See Also

base::lapply

Examples

# Create a list
x <- list(a = 1:10, beta = exp(-3:3), logic = c(TRUE,FALSE,FALSE,TRUE))
class(x) <- "nice"

# compute the list mean for each list element using 'base::lapply'
class(lapply(x, mean))

# To preserve attributes
class(lapply(x, mean, keep.attr = TRUE))


[Package MethylIT version 0.3.1 ]