[Rd] Undocumented 'use.names' argument to c()

William Dunlap wdunlap at tibco.com
Fri Sep 23 19:25:04 CEST 2016


In Splus c() and unlist() called the same C code, but with a different
'sys_index'  code (the last argument to .Internal) and c() did not consider
an argument named 'use.names' special.

> c
function(..., recursive = F)
.Internal(c(..., recursive = recursive), "S_unlist", TRUE, 1)
> unlist
function(data, recursive = T, use.names = T)
.Internal(unlist(data, recursive = recursive, use.names = use.names),
"S_unlist", TRUE, 2)
> c(A=1,B=2,use.names=FALSE)
 A B use.names
 1 2         0

The C code used sys_index==2 to mean 'the last  argument is the 'use.names'
argument, if sys_index==1 only the recursive argument was considered
special.

Sys.funs.c:
 405 S_unlist(vector *ent, vector *arglist, s_evaluator *S_evaluator)
 406 {
 407         int which = sys_index; boolean named, recursive, names;
 ...
 419         args = arglist->value.tree; n = arglist->length;
 ...
 424         names = which==2 ? logical_value(args[--n], ent, S_evaluator)
: (which == 1);

Thus there is no historical reason for giving c() the use.names argument.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Sep 23, 2016 at 9:37 AM, Suharto Anggono Suharto Anggono via
R-devel <r-devel at r-project.org> wrote:

> In S-PLUS 3.4 help on 'c' (http://www.uni-muenster.de/
> ZIV.BennoSueselbeck/s-html/helpfiles/c.html), there is no 'use.names'
> argument.
>
> Because 'c' is a generic function, I don't think that changing formal
> arguments is good.
>
> In R devel r71344, 'use.names' is not an argument of functions 'c.Date',
> 'c.POSIXct' and 'c.difftime'.
>
> Could 'use.names' be documented to be accepted by the default method of
> 'c', but not listed as a formal argument of 'c'? Or, could the code that
> handles the argument name 'use.names' be removed?
> ----------------
> >>>>> David Winsemius <dwinsemius at comcast.net>
> >>>>>     on Tue, 20 Sep 2016 23:46:48 -0700 writes:
>
>     >> On Sep 20, 2016, at 7:18 PM, Karl Millar via R-devel <r-devel at
> r-project.org> wrote:
>     >>
>     >> 'c' has an undocumented 'use.names' argument.  I'm not sure if this
> is
>     >> a documentation or implementation bug.
>
>     > It came up on stackoverflow a couple of years ago:
>
>     > http://stackoverflow.com/questions/24815572/why-does-
> function-c-accept-an-undocumented-argument/24815653#24815653
>
>     > At the time it appeared to me to be a documentation lag.
>
> Thank you, Karl and David,
> yes it is a documentation glitch ... and a bit more:  Experts know that
> print()ing of primitive functions is, eehm, "special".
>
> I've committed a change to R-devel ... (with the intent to port
> to R-patched).
>
> Martin
>
>     >>
>     >>> c(a = 1)
>     >> a
>     >> 1
>     >>> c(a = 1, use.names = F)
>     >> [1] 1
>     >>
>     >> Karl
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list