Re: [R] Merge matrix

From: Pankaj Barah <pankajborah_at_gmail.com>
Date: Wed, 13 Apr 2011 11:05:12 +0200

Hi Kevin,

Sorry.it is not Bt ? A and B are two independent Matrices with equal number rows and different number of columns.

dim (A)
[1] 30380 104

dim(B)

[1] 30380 63

I want to combine both A and B to matrix C wheredim(C) [1] 30380 167

So I got the answer

C<-cbind(A,B)

Thanks and regards,

Pankaj

Regards,

Pankaj

On Tue, Apr 12, 2011 at 5:36 PM, Kevin E. Thorpe <kevin.thorpe_at_utoronto.ca>wrote:

> On 04/12/2011 10:54 AM, pankaj borah wrote:
>
>> I have two matrices A and B
>>
>> dim (A)
>>>
>> [1] 30380 104
>>
>> dim(Bt)
>>>
>>
>> [1] 30380 63
>>
>> I want to combine both A and B to matrix C where
>>
>>> dim(C)
>>>
>> [1] 30380 167
>>
>> How do I do that ?
>>
>>
> Assuming that Bt is the transpose of B and you want C = [A|Bt] you could
> do:
>
> C <- cbind(A,t(B))
>
>
>> Regards,
>>
>> Pankaj Barah
>> Department of Biology,
>> Norwegian University of Science& Technology (NTNU)
>> Realfagbygget, N-7491
>>
>> [[alternative HTML version deleted]]
>>
>>
>>
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
> --
> Kevin E. Thorpe
> Biostatistician/Trialist, Knowledge Translation Program
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: kevin.thorpe_at_utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 13 Apr 2011 - 14:54:50 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 13 Apr 2011 - 15:20:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive