From Kurt.Hornik@ci.tuwien.ac.at  Wed Feb  7 17:36:55 2001
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Wed, 7 Feb 2001 18:36:55 +0100
Subject: [Rd] RE: [R] Removing "row.names"
In-Reply-To: <Pine.A41.4.21.0102070930090.181294-100000@homer37.u.washington.edu>
References: <14977.33920.590610.689408@mithrandir.hornik.net>
 <Pine.A41.4.21.0102070930090.181294-100000@homer37.u.washington.edu>
Message-ID: <14977.34743.548005.545365@mithrandir.hornik.net>

>>>>> Thomas Lumley writes:

> On Wed, 7 Feb 2001, Kurt Hornik wrote:
>> >>>>> Thomas Lumley writes:
>> 
>> > On Wed, 7 Feb 2001, Kurt Hornik wrote:
>> >> >>>>> Peter Dalgaard BSA writes:
>> >> 
>> >> > Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:
>> >> >> names(sampled) <- " "
>> >> >> and
>> >> >> dimnames(sampled)[[2]] <- " "
>> >> >> 
>> >> >> happily introduce non-unique variable names in the data frame.
>> >> >> 
>> >> >> Is the rule that row.names and names must be unique still on?
>> >> >> 
>> >> >> Argh ...
>> >> 
>> >> > Splus 3.4 dispatches on dimnames<-, but not on names<- with the
>> >> > following curious result:
>> >> 
>> >> >> d <- data.frame(a=1:3,b=4:6)
>> >> >> names(d)<-c(" "," ")
>> >> >> d
>> >> 
>> >> > 1 1 4
>> >> > 2 2 5
>> >> > 3 3 6
>> >> >> dimnames(d)[[1]] <- rep(" ",3)  
>> >> > Error in "dimnames<-.data.frame"(d, .A0): column names must be unique
>> >> > Dumped
>> >> 
>> >> > R dispatches similarly, but doesn't check the dimnames in
>> >> > dimnames<-.data.frame. It could do so quite easily. Just add 
>> >> 
>> >> > || any(duplicated(d[[1]])) || any(duplicated(d[[2]]))
>> >> 
>> >> > at the appropriate spot.
>> >> 
>> >> Thomas' view about what should be permitted seems to be different.
>> 
>> > I wouldn't object to making it hard to create duplicated names(), but
>> > I think it would be a bad idea to have data.frame() make up unique
>> > names if it's given non-unique ones.
>> 
>> Maybe `check.names' could also be used for uniqueness testing?
>> 
>> In any case, I think we should specify what *exactly* a data frame is.
>> 

> I think we should specify, and check.names is a logical way to
> allow/forbid non-unique columns.

O.k.  Would the assignment versions of rownames/colnames etc also have
the `check.names' argument for their data frame methods?  Personally I
have no preferences for row/colnames which are, by their naming, more
matrix style.  But I think the ``high-level'' case.names and
variable.names perhaps should ...

> Having a new class would be messy: logically it shouldn't inherit from
> data.frame, data.frame should inherit from it, but that would be a real
> pain to set up.

[Yes, unfortunately.]

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] RE: [R] Removing "row.names"
Kurt Hornik