iapply: Iteratively (recursively) apply a function to its own output

Description Usage Arguments Value Examples

View source: R/Rfunctions.R

Description

Iteratively (recursively) apply a function to its own output

Usage

1
  iapply(X, FUN, init, ...)

Arguments

X

a vector of first arguments to be passed in

FUN

a function taking a changing (x) and an initial argument (init)

init

an argument to be "worked on" by FUN with parameters x[1], x[2], etc.

...

Arguments passed to FUN.

Value

the final value, of the same type as init

Examples

1
2
3
4
5
vec <- "xy12"
mylist <- list( c("x","a"), c("y","b"), c("a","f") )
iapply( mylist , FUN=function(repvec,x) {
  gsub(repvec[1],repvec[2],x)
}, init=vec )

Example output

[1] "fb12"

taRifx documentation built on April 14, 2020, 6:27 p.m.

Related to iapply in taRifx...