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

Andrew Piskorski atp at piskorski.com
Sat Jan 31 13:31:58 CET 2009


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":

  http://bugs.r-project.org/cgi-bin/R/wishlist?id=8192

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>
http://www.piskorski.com/



More information about the R-devel mailing list