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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon 16 Oct 2006 - 12:58:46 GMT

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 <gchappi@gmail.com> 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 same declaration, e.g.
>
> format.default <-
> function(x, trim = FALSE, digits = NULL, nsmall = 0,
> justify = c("left", "right", "centre", "none"),
> width = NULL, na.encode = TRUE, scientific = NA,
> big.mark = "", big.interval = 3,
> small.mark = "", small.interval = 5, decimal.mark = ".",
> zero.print = NULL, ...)
>
> Is there a right way? And if both forms are used, how do I know which
> one is right?
>
> Thanks a lot and best regards,
> Hans-Peter
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 16 23:02:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 16 Oct 2006 - 13:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.