Hello all,

It might be a simple question, but I cannot find the solution, as I do not
know which subjects I should search on. So, much thanks for he/she we can
help me.
I am creating a function and would like to place a formula in the function,
without it being executed immediately. Like saving it temporary as 'text'.

Simplified version of what I would like to be able to do:

test<-function(a,x){
if(a<5){ b<-3+ x[i]}
if(a>5){ b<- 6 + x[i]}
y<-1:10
for (i in 1:10){y[i]<-4 + b}
return(y)
}

In my perfect world, R will replace b in the formula y=4+b by the
appropriate b, indicated by the condition (value of a).
It now takes for 'b' only the first argument of x (+3 or 6). I know I can
solve the problem by also looping over b and turning it into a vector, but
I would like to know if it is also possible in the way stated above. If I
put 3+x[i] in "" to make it a character, it will still be character at
y<-4+b or when I use as.numeric, it will create NA....

Thanks in advance,

Julia

	[[alternative HTML version deleted]]

