[R] Questions about cbind

Sean Davis sdavis2 at mail.nih.gov
Wed Jan 4 12:35:05 CET 2006




On 1/4/06 12:28 AM, "Vincent Deng" <bioflash at gmail.com> wrote:

> Dear R-helpers
> 
> I have a stupid question about cbind function. Suppose I have a
> dataframe like this
> Frame:
> A 10
> C 20
> B 40
> 
> and a numeric matrix like this
> Matrix:
> A 1
> B 2
> C 3
> 
> cbind(Frame[,2],Matrix[,1]) simply binds these two columns without
> checking the order, I mean, the result will be
> A 10 1
> B 20 2
> C 30 3
> 
> rather than
> A 10 1
> B 30 2
> C 20 3
> 
> So my problem is: Is there any solution for R to bind columns with
> correct order?

Look at the merge function.

Sean




More information about the R-help mailing list