[R] Evaluating a function with another function

2006-04-06 Thread Guenther, Cameron
Hello all, I hope someone can help me with this. I have function that calculates two values based on input data. A simple example follows: test-function(x,s,rangit=seq(0,10,1)) { rangit-rangit y-vector() p-vector() for(i in 0:length(rangit)){ y[i]-x+s[1]+rangit[i] p[i]-x+s[2]+rangit[i] }

Re: [R] Evaluating a function with another function

2006-04-06 Thread Gabor Grothendieck
I assume you want a list containing length(x) data frames, one per list component. If that's it try this: test - function(x = 1:4, s = 1:2, rangit = 0:11) lapply(x, function(x) data.frame(rangit, y = x+s[1]+rangit, p=x+s[2]+rangit)) test() # test run On 4/6/06, Guenther, Cameron [EMAIL