Dear Rusers,
I am still an unexperienced builder of functions and loops, so my question is
very basic: Is it possible to introduce a second variable (j) into my loop.
To examplify:
# This works fine:
fn - function (x) {if (x46 x52) 1 else 0}
res -NULL
for (i in 40:60) res -c(res,fn(i))
res
On 7/29/2008 7:55 AM, Oehler, Friderike (AGPP) wrote:
Dear Rusers,
I am still an unexperienced builder of functions and loops, so my question is
very basic: Is it possible to introduce a second variable (j) into my loop.
To examplify:
# This works fine:
fn - function (x) {if (x46 x52) 1 else
Onderwerp: [R] 'for' loop, two variables
Dear Rusers,
I am still an unexperienced builder of functions and loops, so my
question is
very basic: Is it possible to introduce a second variable (j) into my
loop.
To examplify:
# This works fine:
fn - function (x) {if (x46 x52) 1 else 0}
res -NULL
On 29.Jul.2008, at 14:13, ONKELINX, Thierry wrote:
Dear Frederike,
#Both your functions are vectorized. So you don't need loops. Working
with vectorized functions is much faster than looping.
fn - function (x,y) {
ifelse(x46 x52 y12, 1, 0)
}
datagrid - expand.grid(i = 40:60, j = 0:20)
4 matches
Mail list logo