From renaud at mancala.cbio.uct.ac.za  Tue Jan 25 10:27:47 2011
From: renaud at mancala.cbio.uct.ac.za (Renaud Gaujoux)
Date: Tue, 25 Jan 2011 11:27:47 +0200
Subject: [Rd] Missing argument vs. empty argument
Message-ID: <4D3E9793.6040309@cbio.uct.ac.za>

Hi,

is there an easy, robust, and/or recommended way to distinguish a 
missing argument from an empty argument as in:

foo <- function(i, j){
     print(missing(j))
     print(nargs())
}

foo(i)  # TRUE, 1
foo(i,) # TRUE, 2

I know I can work around with nargs, the list of arguments and the names 
of the passed arguments, but I wish there is something already in place 
for this.
This is specially important for '['-like methods where x[i,] is not the 
same as x[i].
What I am looking for is a function that tells me if an argument has 
actually been passed empty:

foo <- function(i, j, k){
     print( empty.arg(j) )
     print(nargs())
}

would result in:

foo(i) # FALSE, 1
foo(i, ) # TRUE, 2
foo(i, j) # FALSE, 2
foo(i, k=2) # FALSE, 2
foo(i, k=2, ) # TRUE, 3

Thank you for any help or pointer.

Bests,
Renaud


 

###
UNIVERSITY OF CAPE TOWN 

This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}



[Rd] Missing argument vs. empty argument
Renaud Gaujoux