From p.dalgaard@biostat.ku.dk  Fri Aug  6 08:42:23 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 06 Aug 1999 09:42:23 +0200
Subject: cbind is not generic as claimed, omits labels where S has them (PR#239)
In-Reply-To: Ross Ihaka's message of "Fri, 6 Aug 1999 14:55:34 +1200"
References: <199908051128.NAA28801@pubhealth.ku.dk> <19990806095312.A15303@stat1.stat.auckland.ac.nz> <x2lnbp7uey.fsf@blueberry.kubism.ku.dk> <19990806145534.A3584@stat1.stat.auckland.ac.nz>
Message-ID: <x2u2qd8ie8.fsf@blueberry.kubism.ku.dk>

Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:

> On Fri, Aug 06, 1999 at 12:08:05AM +0200, Peter Dalgaard BSA wrote:
> > Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:
> > 
> > I played around with this earlier today. There's nothing special about
> > dataframes, S does the same with any classed object. I.e.
> > 
> > class(b)<-"my"
> > cbind.my<-function(...)match.call()
> > 
> > cbind(a,b)
> > 
> > will dispatch cbind.my
> 
> I played some more.  I think data frames are special somehow.
> 
> 	S> x <- factor(1:10)
> 	S> y <- data.frame(1:10)
> 	> class(x)
> 	[1] "factor"
> 	S> class(y)
> 	[1] "data.frame"
> 	S> class(cbind(x,y))
> 	[1] "data.frame"
> 	S> class(cbind(y,x))
> 	[1] "data.frame"
> 
> They seem to overpower other class arguments too.

This is because there's no cbind.factor:

S> cbind.factor<-function(...) match.call()
S> cbind(x,y)
      x           y 
X1.10 1 numeric, 10
attr(, "names"):
[1] ""      "X1.10"
Warning messages:
1: Incompatible methods ("cbind.factor", "cbind.data.frame") for "cbind"
2: Number of rows of result is not a multiple of vector length (arg 1) in: cbin
	d(x, y)

(and cbind.data.frame just calls data.frame(...) so it's little wonder
that the result is always a data frame)

-- 
   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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


cbind is not generic as claimed, omits labels where S has them (PR#239)
Peter Dalgaard BSA