[R] Where is list.names?

Göran Broström gor@n@bro@trom @end|ng |rom umu@@e
Wed Mar 30 12:43:52 CEST 2022



On 2022-03-30 11:48, Ivan Krylov wrote:
> В Wed, 30 Mar 2022 11:27:05 +0200 Göran Broström
> <goran.brostrom using umu.se> пишет:
> 
>> I can guess what 'list.names' is (from the documentation), but
>> where and how is it defined?
> 
> Interesting! It's defined first thing inside the function, so by the 
> time the function tries to use the argument, list.names exists and
> can be called, but for all other purposes, it's not there.

Thanks for that (also thanks to Eric)!

> 
> What if you don't set a default value for dnn in your wrapper or

That works, if I check for missing argument:


table <- function(...,
                   useNA = "ifany",
                   exclude = if (useNA == "no") c(NA, NaN),
                   dnn,
                   deparse.level = 1){
     if (missing(dnn)){
         base::table(...,
                     exclude = exclude,
                     useNA = useNA,
                     deparse.level = deparse.level)
     }else{
         base::table(...,
                     useNA = useNA,
                     exclude = exclude,
                     dnn = dnn,
                     deparse.level = deparse.level)
     }
}

Is this the final word?

Göran

> even mention dnn as a formal argument in your wrapper? In many cases,
> it's possible to forward missing arguments to functions and have them
> do the right thing. The only other solution I can think of is
> non-standard evaluation.
>



More information about the R-help mailing list