Learn R Programming

taRifx (version 1.0.6.2)

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

Description

Iteratively (recursively) apply a function to its own output

Usage

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

Run this code
# NOT RUN {
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 )
# }

Run the code above in your browser using DataLab