[R] Passing a missing argument

David Lindelof lindelof at ieee.org
Sun May 27 21:26:59 CEST 2007


Dear userRs,

Is there a way to explicitly set an argument to a function call as
missing?

E.g.,

histogram(foo,
          bar,
          endpoints=ifelse(!missing(limits),limits,NA/NULL/whatever)))

In this call I want to set a value to the endpoints argument only if the
`limits' variable has been set, and leave the defaults otherwise.

The only way I could do it is thus:

if (!missing(limits)) histogram(foo,bar,endpoints=limits)
else histogram(foo,bar)

Is there a cleaner way?

Kind regards,

David Lindelof



More information about the R-help mailing list