Showing posts with label successively. Show all posts
Showing posts with label successively. Show all posts
Applying a function successively in R
At the R in Finance conference Paul Teetor gave a fantastic talk about Fast(er) R Code. Paul mentioned the common higher-order function Reduce, which I hadn't used before.
Reduce allows me to apply a function successively over a vector.
What does that mean? Well, if I would like to add up the figures 1 to 5, I could say: oradd <- function(x,y) x+y
add(add(add(add(1,2),3),4),5)
Reduce(add, 1:5)
3 Jul 2012
07:36
googleVis
,
R
,
Reduce
,
successively
,
Tutorials
