[R] lapply - function with arguments

2010-04-13 Thread Randall Wrong
Dear R users, I have created a function f of n, a and b : f(n,a,b) I would like to apply this function several times to some values of n. a and b are held constant. I was thinking of using lapply. How can I do this ? Thank you very much Randall [[alternative HTML version deleted]]

Re: [R] lapply - function with arguments

2010-04-13 Thread jim holtman
lapply(yourList, f, a=1, b=2) On Tue, Apr 13, 2010 at 9:11 AM, Randall Wrong randall.wr...@gmail.comwrote: Dear R users, I have created a function f of n, a and b : f(n,a,b) I would like to apply this function several times to some values of n. a and b are held constant. I was thinking of

Re: [R] lapply - function with arguments

2010-04-13 Thread Randall Wrong
Thank you Jim 2010/4/13 jim holtman jholt...@gmail.com lapply(yourList, f, a=1, b=2) On Tue, Apr 13, 2010 at 9:11 AM, Randall Wrong randall.wr...@gmail.comwrote: Dear R users, I have created a function f of n, a and b : f(n,a,b) I would like to apply this function several times to

Re: [R] lapply - function with arguments

2010-04-13 Thread Arun.stat
another thought possibly fn = function(n, a=1, b=3) return(n*(a+b)) sapply(1:3, fn) -- View this message in context: http://n4.nabble.com/lapply-function-with-arguments-tp1838373p1838506.html Sent from the R help mailing list archive at Nabble.com.