From p.dalgaard@biostat.ku.dk  Wed Feb  7 16:06:03 2001
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 07 Feb 2001 17:06:03 +0100
Subject: [Rd] RE: [R] Removing "row.names"
In-Reply-To: Kurt Hornik's message of "Wed, 7 Feb 2001 16:45:58 +0100"
References: <200102071105.LAA08910@achill.nmrc.ucc.ie> <NEBBJKDJHEFCOOLFFAKKIEMFCAAA.cyg@sympatico.ca> <14977.28086.8858.910911@mithrandir.hornik.net>
Message-ID: <x2g0hqbhqs.fsf@blueberry.kubism.ku.dk>

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. 
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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"
Peter Dalgaard BSA