[R] "Fold" in R?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Mar 27 19:43:01 CEST 2005
Seung Jun <jun at 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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list