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 (x>46 & x<52) 1 else 0}    
res <-NULL 
for (i in 40:60) res <-c(res,fn(i))
res

# But here, there is an error in the "for" expression:
fn <- function (x,y) {if (x>46 & x<52 & y<12) 1 else 0 }    
res <-NULL 
for (i in 40:60 & j in 0:20) res <-c(res,fn(i,j)) 
# How do I have to write the expression "i in 40:60 & j in 0:20"? Or is there
no way to do that, i.e. I have to do the calculation in two steps?

Thanks in advance!
Friderike

	[[alternative HTML version deleted]]

