elementwise: Apply a function to each element of an lvec

Description Usage Arguments Value Examples

View source: R/elementwise.R

Description

Apply a function to each element of an lvec

Usage

1
elementwise(x, fun, ...)

Arguments

x

an object of type lvec.

fun

the function to apply to the lvec. This function receives chunks of the lvec (which are regular R-vector) and should return a (R) vector of the same length as its input.

...

passed on to fun.

Value

Returns a link{lvec} of the same length as the input. The type is determined by the output of fun.

Examples

1
2
3
4
5
# Calculate square root of lvec
x <- as_lvec(1:10)
y <- elementwise(x, sqrt)
# of course, this is already implemented
sqrt(x)

ldat documentation built on March 26, 2020, 7:59 p.m.

Related to elementwise in ldat...