[R] cbind order

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri May 30 13:02:11 CEST 2003


orkun <temiz at deprem.gov.tr> writes:

> Hello
> 
> I need to use this command:
> cbind(ftable(xtabs(cnt~geo+slp+con+hey,data=dt3))
> hey is in count of success /failure value
> but cbind gives failure/success counts. I want to change the order of
> this cbind as  success /failure counts.
> for instance:
> I want cbind to give counts as 32-4552 rather than 4552-32
> 
> 
> what should I do ?

Well, all cbind does in that context is to remove the embellishments
of the ftable structure, exposing the N x 2 internal matrix. Various
other matrix operations, including indexing, has the same effect, e.g.

data(Titanic)
ftable(Titanic, row.vars = 1:3)[,]    # same as using cbind()
ftable(Titanic, row.vars = 1:3)[,2:1] # what you want

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list