[Rd] (PR#8192) [ subscripting sometimes loses names

From: Andrew Piskorski <atp_at_piskorski.com>
Date: Sat, 31 Jan 2009 07:31:58 -0500

This (tangential) discussion really should be a separate thread so I changed the subject line above.

On Fri, Jan 30, 2009 at 11:51:00AM -0500, Simon Urbanek wrote:
> Subject: Re: [Rd] (PR#13487) Segfault when mistakenly calling [.data.frame

> >My boss was debugging an issue in our R code. We have our own "[...."
> >functions, because stock R drops names when subscripting.
> ... if you tell it to do so, yes. If you tell it to not do that, it
> won't ... ever tried drop=FALSE ?

Simon, no, the drop=FALSE argument has nothing to do with what Christian was talking about. The kind of thing he meant is PR# 8192, "Subject: [ subscripting sometimes loses names":


In R, subscripting with "[" USUALLY retains names, but R has various edge cases where it (IMNSHO) inappropriately discards them. This occurs with both .Primitive("[") and "[.data.frame". This has been known for years, but I have not yet tried digging into R's implementation to see where and how the names are actually getting lost.

Incidentally, versions of S-Plus since approximately S-Plus 6.0 back in 2001 show similar buggy edge case behavior. Older versions of S-Plus, c. S-Plus 3.3 and earlier, had the correct, name preserving behavior. I presume that the original Bell Labs S had correct name-preserving behavior, and then the S-Plus developers broke it sometime along the way.

Andrew Piskorski <atp_at_piskorski.com>

R-devel_at_r-project.org mailing list
Received on Sat 31 Jan 2009 - 13:34:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 01 Feb 2009 - 19:30:35 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.

list of date sections of archive