Re: [Rd] good practice for values not provided

2006-11-19 Thread Duncan Murdoch
On 11/19/2006 3:46 PM, Tamas K Papp wrote: > Hi, > > I am writing a collection of functions which I plan to share as a > package later (when they are tested thoroughly), so I would like to do > things "right" from the beginning... > > I encountered a minor question of style. Consider a function

Re: [Rd] good practice for values not provided

2006-11-19 Thread Gabor Grothendieck
One possibility is: f <- function(a, b, x) if (missing(x)) a+b else a-b-x although that does have the disadvantage that one cannot explicitly tell it not to use x but rather its denoted by its absence. On 11/19/06, Tamas K Papp <[EMAIL PROTECTED]> wrote: > Hi, > > I am writing a collection of fu

[Rd] good practice for values not provided

2006-11-19 Thread Tamas K Papp
Hi, I am writing a collection of functions which I plan to share as a package later (when they are tested thoroughly), so I would like to do things "right" from the beginning... I encountered a minor question of style. Consider a function f <- function(a,b,x=NULL) { ## ... } if !is.null(x),

Re: [Rd] array indexes in C

2006-11-19 Thread Tamas K Papp
Hi Ben, Thanks for your answer. I looked at the status of VLA on the GCC homepage and it appears to be "broken". [1] Do you think that the code below still works? Or are you using a different compliler? Thanks, Tamas [1] http://gcc.gnu.org/c99status.html On Sun, Nov 19, 2006 at 09:55:17AM -

[Rd] array indexes in C

2006-11-19 Thread Benjamin Tyner
Tamas, You could write convenience functions, but I have used the C99 mechanism for variable length arrays with no problems calling from R. One thing you have to keep in mind though is that (as far as I know) the dimensions must be passed before the array reference. So for example, r <- .C("fo