[R] Vectorizing a function: what does it mean?

2011-05-09 Thread Ron Michael
Dear all, I would really appreciate if somebody can help me to understand what does the phrase Vectorize your function mean? And what is the job of Vectorize() function in doing that? I have read many threads where experts suggest to Vectorize the function, which will speed up entire

Re: [R] Vectorizing a function: what does it mean?

2011-05-09 Thread David Winsemius
On May 9, 2011, at 11:57 AM, Ron Michael wrote: Dear all, I would really appreciate if somebody can help me to understand what does the phrase Vectorize your function mean? And what is the job of Vectorize() function in doing that? I have read many threads where experts suggest to

Re: [R] Vectorizing a function: what does it mean?

2011-05-09 Thread Duncan Murdoch
On 09/05/2011 1:31 PM, David Winsemius wrote: On May 9, 2011, at 11:57 AM, Ron Michael wrote: Dear all, I would really appreciate if somebody can help me to understand what does the phrase Vectorize your function mean? And what is the job of Vectorize() function in doing that? I have read

Re: [R] Vectorizing a function: what does it mean?

2011-05-09 Thread Duncan Murdoch
On 09/05/2011 11:57 AM, Ron Michael wrote: Dear all, I would really appreciate if somebody can help me to understand what does the phrase Vectorize your function mean? And what is the job of Vectorize() function in doing that? I have read many threads where experts suggest to Vectorize the

[R] Vectorizing a function that needs to access previous elements of a row

2010-11-20 Thread Amol Shelat
Hi, I'm a newbie when it comes to R, and I'm trying to figure out how to use vectorization as opposed to for loops. In particular, how can I create a function that is applied on each element of a row, but can access previous elements relative to that element? My problem: I want to calculate

Re: [R] Vectorizing a function that needs to access previous elements of a row

2010-11-20 Thread Joshua Wiley
Hi Amol, It depends on your exact needs, but one way, assuming you do not need to access previous calculations, only previous elements: x - 1:10 x[-10] / x[-1] The idea is first create a vector, x, then using negative indices, select the first 9 elements of x (i.e., 1:9) to be divded by the

[R] vectorizing a function

2009-07-07 Thread Steve Jaffe
I'm sure I'm missing something obvious but I'm not seeing how to simply vectorize a function of two or more variables. Say I have f - function(x,y) if (x0) y else -y Now I have vectors x and y of equal length and I'd like to apply f element-wise. I.e. conceptually z - f(x,y) where x, y, z are

Re: [R] vectorizing a function (NEVERMIND)

2009-07-07 Thread Steve Jaffe
Nevermind, indeed it is obvious: Vectorize ! Steve Jaffe wrote: I'm sure I'm missing something obvious but I'm not seeing how to simply vectorize a function of two or more variables. -- View this message in context: http://www.nabble.com/vectorizing-a-function-tp24380064p24380136.html

Re: [R] vectorizing a function

2009-07-07 Thread Greg Snow
- project.org] On Behalf Of Steve Jaffe Sent: Tuesday, July 07, 2009 1:42 PM To: r-help@r-project.org Subject: [R] vectorizing a function I'm sure I'm missing something obvious but I'm not seeing how to simply vectorize a function of two or more variables. Say I have f - function(x,y

Re: [R] vectorizing a function

2009-07-07 Thread Bert Gunter
?ifelse Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Jaffe Sent: Tuesday, July 07, 2009 12:42 PM To: r-help@r-project.org Subject: [R] vectorizing a function I'm sure I'm