Using R 2.4, the following fails: setClass("testc", representation(a="ANY")) makeC <- function(myarg) new("testc", a=myarg) makeC() -> Error in initialize(value, ...) : argument "myarg" is missing, with no default
On the other hand, this is OK: f <- function(a) g(b=a) g <- function(b) if(missing(b)) "missing" else "valid arg" g() -> "missing" By the way, new("testc") succeeds. Is there a good way around this? Since my real example has several 4 arguments that might be missing, testing on missingness and calling "new" with appropriate explicit arguments is not an attractive option. Passing all the arguments in is also not an option, since my call to "new" includes an argument not in the constructor (i.e., my equivalent of makeC). I suspect there's something I could do to get the constructor arguments, modify the list (i.e., delete args that were missing and insert new ones), and do.call(new, myArgList). Not only am I unsure how to do that (or if it would work), I'm hoping there's a better way. What's the best approach to this problem? ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel