[R] data management on R

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Mar 24 08:51:59 CET 2006


"linda.s" <samrobertsmith at gmail.com> writes:

> On 3/23/06, Jim Porzak <jporzak at gmail.com> wrote:
> > C <- cbind(A[, 1], B[, 2])
> >
> >
> The result is:
>      [,1] [,2]
> [1,]    1    2
> [2,]    3    8
> How to keep x and n as the column title?
> Linda

Provided that A and B are data frames:

 cbind(A[1], B[2])

For matrices, you need to use A[,1,drop=FALSE] etc. to get around the
issue of single-column extraction. Or

 cbind(A,B)[,c("x","n")]



-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list