RE: [R] Retrieve ... argument values

2003-09-17 Thread Richard A. O'Keefe
Ben Bolker [EMAIL PROTECTED] wrote: Yes, although this becomes tedious if (e.g.) you have a function that calls two different functions, each of which has many arguments (e.g. plot() and barplot(); then you have to set up a whole lot of arguments that default

Re: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)

2003-09-17 Thread Prof Brian Ripley
On Wed, 17 Sep 2003, Simon Fear wrote: There have been various elegant solutions to test for the presence of a particular named parameter within a ... argument, such as if (!is.null(list(...)$ylim)) if (ylim %in% names(list(...))) I think I'd have to comment these lines pretty clearly if

RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)

2003-09-17 Thread Simon Fear
Thanks for the insight. -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] snip dots - list(...) haveYlim - ylim %in% names(dots) is the sort of thing we still understand 5 years later. I didn't say understand, I said easily follow. Obviously how easily is

Re: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)

2003-09-17 Thread Tony Plate
At Wednesday 11:19 AM 9/17/2003 +0100, Simon Fear wrote: There have been various elegant solutions to test for the presence of a particular named parameter within a ... argument, such as if (!is.null(list(...)$ylim)) if (ylim %in% names(list(...))) I think I'd have to comment these lines pretty

RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)

2003-09-17 Thread Simon Fear
Tony, I don't understand what you mean. Could you give an example? -Original Message- From: Tony Plate [mailto:[EMAIL PROTECTED] ... I'm not saying never write functions that use ..., I'm just saying never write functions that depend on a particular argument being passed via

RE: Just don't do it, surely? (was RE: [R] Retrieve ... argument values)

2003-09-17 Thread Tony Plate
Simon, I agree, for some (maybe most) arguments it is good to know what defaults are being used. But there are some for which I really don't want to know. An example of the latter is arguments that control interaction with a database. Suppose I have a low-level interaction function that

Re: [R] Retrieve ... argument values

2003-09-16 Thread Thomas Lumley
On Tue, 16 Sep 2003 [EMAIL PROTECTED] wrote: Dear R users, I want to retrieve ... argument values within a function. Here is a small exmaple: myfunc - function(x, ...) { if (hasArg(ylim)) a - ylim plot(x, ...) } One solution is dots-substitute(list(...))

RE: [R] Retrieve ... argument values

2003-09-16 Thread Simon Fear
For most purposes a more useful technique is to write the function with a default NULL argument myfunc - function(x, ylim=NULL) so that it can be called as myfunc(x) or myfunc(x,y). Inside the function you test for !is.null(ylim) and take appropriate action. Alternatively, and maybe more

Re: [R] Retrieve ... argument values

2003-09-16 Thread Peter Dalgaard BSA
[EMAIL PROTECTED] writes: Dear R users, I want to retrieve ... argument values within a function. Here is a small exmaple: myfunc - function(x, ...) { if (hasArg(ylim)) a - ylim plot(x, ...) } x - rnorm(100) myfunc(x, ylim=c(-0.5, 0.5)) Error in myfunc(x, ylim =

Re: [R] Retrieve ... argument values

2003-09-16 Thread Thomas W Blackwell
Huan - Look at the function code for order(). To show the function definition, type just order at the command line (no quotes, no parentheses). This example is what I found most useful when I had a similar question. The green book is also useful. - tom blackwell - u michigan medical

RE: [R] Retrieve ... argument values

2003-09-16 Thread Liaw, Andy
Try: myfunc - function(x, ...) { if (hasArg(ylim)) a - ...$ylim plot(x, ...) } HTH, Andy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2003 10:14 AM To: [EMAIL PROTECTED] Subject: [R] Retrieve ... argument

RE: [R] Retrieve ... argument values

2003-09-16 Thread Simon Fear
. -Original Message- From: Ben Bolker [mailto:[EMAIL PROTECTED] Sent: 16 September 2003 16:18 To: Simon Fear Cc: [EMAIL PROTECTED]; R help list Subject: RE: [R] Retrieve ... argument values Security Warning: If you are not sure an attachment is safe to open please contact Andy on x234

RE: [R] Retrieve ... argument values

2003-09-16 Thread Ben Bolker
Yes, although this becomes tedious if (e.g.) you have a function that calls two different functions, each of which has many arguments (e.g. plot() and barplot(); then you have to set up a whole lot of arguments that default to NULL and, more annoyingly, you have to document them all in