[R] iterating missing() over function arguments

Harry Mamaysky h.mamaysky at gmail.com
Fri Aug 9 14:42:04 CEST 2013


Hi,

Say I have

   function(aa,bb,cc) { does something }

and I want to go through all (or a subset) of function arguments to check if
they're missing.  Of course, I can check each one in turn, ie.

      if (missing(aa)) {}
      if (missing(bb)) {}, etc.

But is there a construct like the following to go through all of them and
perform some default action?  Like this (which doesn't work obviously):

   for el in c('aa','bb','cc')
       if missing(el)  {do something}

I was thinking could to eval(parse( <construct string here> )), but was
hoping there was something cleaner.

Thanks



More information about the R-help mailing list