Re: [Rd] Questions about imports to a namespace

From: Simon Knapp <>
Date: Thu, 05 Jul 2012 12:04:20 +1000

Thanks Duncan.

wrt question 4, I see your point about passing arguments. Maybe R could do with a value "MISSING" or "DEFAULT" for this and other similar purposes. The test for can be frustrating when the argument (when not NA) has length greater than 1 as it produces a warning. But in some situations NULL won't suffice. Consider this contrived (and simplified) example to demonstrate the sort of situation I mean (contrived in that test for NA is not required for the case of setdiff).

mapply(function(x, y, z) {

    if(! x <- setdiff(x, y)
}, x, c(NA, x[-length(x)]), MoreArgs = list(z), SIMPLIFY=F)

where x is a list (and z a vector). One should really make the test "if(length(y) > 1 && !"... but is there a nicer way?

Thanks again,

On Tue, Jul 3, 2012 at 8:41 PM, Duncan Murdoch <> wrote:
> On 12-07-02 10:53 PM, Simon Knapp wrote:


>> 4) Is it better to check for arguments that are missing, or use a
>> default value of, say, NA; i.e. is missing(arg) preferable to
> That depends. It's easier to set an argument to a special value in a call
> from another function than it is to conditionally set it to be missing, but
> there are only a couple of general purpose choices for "missing" values: NA
> and NULL, and you might want a user to be able to specify those. (You can
> also use negative values for counts, etc., in particular contexts.)


> Duncan Murdoch mailing list Received on Thu 05 Jul 2012 - 02:11:44 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 Jul 2012 - 15:40:31 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive