Re: [R] Using lapply when there are dependencies

2015-05-28 Thread Jeff Newmiller
For loops are not slow. Inefficient memory management in for loops is slow. Feel free to preallocate your output vectors and write for loops to your heart's content. If you really want speed you can write this in C++ using Rcpp [1]. If your f() is a standard digital filter algorithm this has

Re: [R] Using lapply when there are dependencies

2015-05-28 Thread David Winsemius
On May 27, 2015, at 4:34 PM, blue honour via R-help wrote: Hi all, Let's say I have a vector: vv-c(1,2,3) And suppose I have a function f(a,b), which is a function of 2 scalar inputs. I would like to evaluate this function separately for each element of the vv vector while the

Re: [R] Using lapply when there are dependencies

2015-05-28 Thread PIKAL Petr
Hi -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of blue honour via R-help Sent: Thursday, May 28, 2015 1:34 AM To: r-help@r-project.org Subject: [R] Using lapply when there are dependencies Hi all, Let's say I have a vector: vv-c(1,2,3

Re: [R] Using lapply when there are dependencies

2015-05-28 Thread blue honour via R-help
Winsemius dwinsem...@comcast.net wrote: Subject: Re: [R] Using lapply when there are dependencies Cc: r-help@r-project.org Date: Thursday, May 28, 2015, 7:02 AM On May 27, 2015, at 4:34 PM, blue honour via R-help wrote: Hi all, Let's say I have a vector: vv-c(1,2,3

[R] Using lapply when there are dependencies

2015-05-27 Thread blue honour via R-help
Hi all, Let's say I have a vector: vv-c(1,2,3) And suppose I have a function f(a,b), which is a function of 2 scalar inputs. I would like to evaluate this function separately for each element of the vv vector while the second input to f( ) will be the previous output from f( ). So, the