[R] NULL or NA for missing function arguments?

2006-10-16 Thread Hans-Peter
Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the R code that I have looked at, it seems that both forms are used (NULL seems to be used more often though). Sometimes both variants are in the same declaration, e.g. format.default -

Re: [R] NULL or NA for missing function arguments?

2006-10-16 Thread Gabor Grothendieck
There is also a third way, namely use the missing function in the code: f - function(x) if (missing(x)) print(missing) else print(x) f() On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote: Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the

Re: [R] NULL or NA for missing function arguments?

2006-10-16 Thread Duncan Murdoch
On 10/16/2006 8:47 AM, Hans-Peter wrote: Hi, I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. In the R code that I have looked at, it seems that both forms are used (NULL seems to be used more often though). Sometimes both variants are in the

Re: [R] NULL or NA for missing function arguments?

2006-10-16 Thread Hans-Peter
2006/10/16, Duncan Murdoch [EMAIL PROTECTED]: As Gabor said, the third way is to give no default, but test missing() in the code. I forgot this one, thank you. In my case it is probably not suited as I just pass the arguments to a C (Pascal) function and do the checking there. [explanations

Re: [R] NULL or NA for missing function arguments?

2006-10-16 Thread Gabor Grothendieck
On 10/16/06, Hans-Peter [EMAIL PROTECTED] wrote: 2006/10/16, Duncan Murdoch [EMAIL PROTECTED]: As Gabor said, the third way is to give no default, but test missing() in the code. I forgot this one, thank you. In my case it is probably not suited as I just pass the arguments to a C (Pascal)

Re: [R] NULL or NA for missing function arguments?

2006-10-16 Thread Duncan Murdoch
On 10/16/2006 5:06 PM, Brahm, David wrote: Hans-Peter [EMAIL PROTECTED] wrote: I am troubled by the use of NULL or NA to indicate missing/non-specified function arguments. I suggest using NULL for arguments which are vectors or lists of unspecified length, and NA for scalars (arguments