Re: [Rd] undocumented name mangling during unlist?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 09 Jan 2007 - 16:30:22 GMT

On Mon, 8 Jan 2007, Seth Falcon wrote:

> The documentation for unlist says:
>
> By default, 'unlist' tries to retain the naming information
> present in 'x'. If 'use.names = FALSE' all naming information is
> dropped.
>
> Hence, I find it odd that I see the following:
>
> > b <- list("highway1"=1:5)
> > unlist(b)
> highway11 highway12 highway13 highway14 highway15
> 1 2 3 4 5
>
> I suspect this is essential behavior for something or other, but it
> seems that this approach is inefficient for large lists and in many
> contexts does not preserve names, but invents new ones.

There is the information that the entries came from element "highway1" which needs to be preserved. c() and unlist() share code, and both try to create different names for elements of different origin.

Why is this 'inefficient' (names are optional) and what do you propose that meets the conditions?

It is probably not coincidental that S3 did this the same way.

>
> /me ducks
>
> + seth
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Jan 10 03:34:11 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 10 Jan 2007 - 03:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.