[Roxygen-devel] parameters with default NULL value

Manuel J. A. Eugster Manuel.Eugster at stat.uni-muenchen.de
Tue Feb 2 08:58:25 CET 2010


Hi Felix and all others,

thanks for the Bug-Report and the proposed fix. During testing the fix
proposed by Melissa for the NULL value problem, I also detected that there
are some more problems (that's why the proposed fix from Melissa is not in
the package yet).

I have no time to fix this problem this week (two deadlines, today and on
friday :-), but then I have time to focus on this problem ... I'll come
back to you next week, to check if the new code is running for your
source code.


Manuel.



Felix Andrews schrieb:
> Hi all,
> 
> I was just looking at this thread from a couple of weeks ago:
> http://lists.r-forge.r-project.org/pipermail/roxygen-devel/2010-January/000115.html
> proposing a change to the function parse.formals in parse.R.
> 
> However a more complete change is required to fix not just the "NULL"
> bug but also the problem with long default arguments.
> 
> Rather than
> 
>   if (is.null(formals)) formals
>   else list(formals=Map(function(formal)
>               if (is.null(formal)) ''
>               else if (is.call(formal)) capture.output(formal)
>               else as.character(maybe.quote(formal)), formals))
> 
> I propose
> 
>   if (is.null(formals)) formals
>   else list(formals = lapply(formals, function(formal)
>       paste(deparse(formal, width=500, control=c()), collapse = "")
>     )
> 
> 
> Example:
> 
> foo <- function(x, d = NULL, a = "hi", asdasd = list(asd = list(x = 1)))
>     { x }
> 
> lapply(formals(foo), function(formal)
>       paste(deparse(formal, width=500, control=c()), collapse = "")
>     )
> $x
> [1] ""
> 
> $d
> [1] "NULL"
> 
> $a
> [1] "\"hi\""
> 
> $asdasd
> [1] "list(asd = list(x = 1))"
> 
> 
> 
> 


More information about the Roxygen-devel mailing list