Re: [R] "Fold" in R?

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 28 Mar 2005 - 03:43:01 EST

Seung Jun <jun@cc.gatech.edu> writes:

> Fold in Mathematica (or reduce in Python) works as follows:
>
> Fold[f, x, {a, b, c}] := f[f[f[x,a],b],c]
>
> That is, f is a binary operator, x is the initial value, and the
> results are cascaded along the list. I've found it useful for
> reducing lists when I only have a function that accepts two arguments
> (e.g., merge in R).
>
> Is there any R equivalent? I'm a newbie in R and having a hard time
> finding such one. Thank you.

Tried searching the mailing list for "Fold"? It was discussed on this very list in November.

http://cran.r-project.org/search.html
http://maths.newcastle.edu.au/~rking/R/

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Mar 28 03:49:54 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST