Re: [R] Help with functions as arguments

2013-02-12 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/13 08:30, Ian Renner wrote: Hi, I am trying to write a function which defines some arguments, then uses those arguments as arguments of other function calls. It's a bit tricky to explain, so a simple example will have to suffice. I

Re: [R] Help with functions as arguments

2013-02-12 Thread Barry Rowlingson
On Tue, Feb 12, 2013 at 7:30 AM, Ian Renner ian_ren...@yahoo.com wrote: Where I am running into trouble is when I want to call function f1 within function f2: f2(x = 3, z = f1(x)) This returns the error: Error in f1(x) : object 'x' not found I'm not sure how to define environments

Re: [R] Help with functions as arguments

2013-02-12 Thread Jan T Kim
On Tue, Feb 12, 2013 at 09:38:19AM +0100, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/13 08:30, Ian Renner wrote: Hi, I am trying to write a function which defines some arguments, then uses those arguments as arguments of other function calls. It's

Re: [R] Help with functions as arguments

2013-02-12 Thread Duncan Murdoch
On 13-02-12 5:34 AM, Jan T Kim wrote: On Tue, Feb 12, 2013 at 09:38:19AM +0100, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/13 08:30, Ian Renner wrote: Hi, I am trying to write a function which defines some arguments, then uses those arguments as arguments of

Re: [R] Help with functions as arguments

2013-02-12 Thread Frans Marcelissen
Hi Ian, The remark of Rainer is correct, but I think the solution is very simpe: f1 = function(a) { b = a + 1 b } f2 = function(x, z) { y = x*z(x) -2 y } f2(x = 3, z = f1) [1] 10 Or are you intending something else? Best wishes, Frans -Oorspronkelijk bericht- Van:

Re: [R] Help with functions as arguments

2013-02-12 Thread David Winsemius
On Feb 12, 2013, at 12:38 AM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/13 08:30, Ian Renner wrote: Hi, I am trying to write a function which defines some arguments, then uses those arguments as arguments of other function calls. It's a bit tricky