<div class="gmail_quote">Hi, Melissa,</div><div class="gmail_quote"><br></div><div class="gmail_quote">This has been bugging me as well.  Thanks for the fix!  Any chance that this will make it into the main source tree?</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Best,</div><div class="gmail_quote">Charles</div><div class="gmail_quote"><br></div><div class="gmail_quote">From: Melissa Jane Hubisz &lt;<a href="mailto:mjhubisz@cornell.edu">mjhubisz@cornell.edu</a>&gt;<br>

Date: Tue, Jan 19, 2010 at 10:31 AM<br>
Subject: parameters with default NULL value<br>
To: <a href="mailto:roxygen-devel@lists.r-forge.r-project.org">roxygen-devel@lists.r-forge.r-project.org</a><br>
<br>
<br>
Hello,<br>
I&#39;ve been developing a fairly large package in R and was thrilled to<br>
discover roxygen.  Thank you for providing this useful tool!<br>
<br>
I  have been using the most recent version of roxygen from the SVN<br>
repository.  One problem I have encountered is that the &quot;usage&quot; is not<br>
displayed properly if a function has parameters whose default value is<br>
NULL.  For example, the function:<br>
myfunc &lt;- function(a, b=NULL, c=0) {NULL}<br>
<br>
will have the documentation:<br>
Usage:<br>
 myfunc(a, b, c=0)<br>
<br>
which incorrectly implies that b is a required parameter.<br>
<br>
I did a bit of poking around and this seems to have a simple fix, by<br>
changing the function parse.formals in parse.R to:<br>
<br>
parse.formals &lt;- function(expressions) {<br>
 formals &lt;- NULL<br>
 call &lt;- car(expressions)<br>
 if (is.call(call)) {<br>
   f &lt;- cadr(expressions)<br>
   if (is.function.definition(f))<br>
     formals &lt;- tryCatch(formals(eval(call)),<br>
                         error=function(e) NULL)<br>
 }<br>
 if (is.null(formals)) formals<br>
 else list(formals=Map(function(formal)<br>
             if (is.null(formal)) &#39;NULL&#39;                #THIS IS THE<br>
ONLY CHANGE, it used to be the empty string &#39;&#39;<br>
             else if (is.call(formal)) capture.output(formal)<br>
             else as.character(maybe.quote(formal)), formals))<br>
}<br>
<br>
Not being very familiar with the inner workings of roxygen, I&#39;m not<br>
sure if this hack will break anything else, but it seems to work for<br>
me.  If it is a proper solution, could it be incorporated into<br>
roxygen?  If not, is there another way to fix this?<br>
<br>
Thanks again for your work on this.  It&#39;s been a huge timesaver for me.<br>
-Melissa<br>
<br>
Melissa Hubisz<br>
Department of Biological Statistics and Computational Biology<br>
Cornell University<br>
</div><br>