[R] combining two (or more) tables by creating another dimension

From: Georg Ehret <georgehret_at_gmail.com>
Date: Wed, 23 Apr 2008 16:26:37 -0400


Dear R community, I wish to combine two tables in one by adding an additional dimension:

e.g.:
>

t1<-as.table(matrix(rnorm(40),nrow=4,ncol=10));rownames(t1)<-c("rowone","rowtwo","rowthree","rowfour")
> t1

                   A           B           C           D           E
  F           G           H           I           J
rowone -1.04203810 -0.05148987 -1.74162922 0.02683198 -0.28622512 -0.87690444 -0.12335543 -0.60394319 -0.15923255 0.53235864 rowtwo -1.01168507 1.07785313 -0.17483300 -0.60747916 1.12944895  0.89512881 0.13972544 0.05006999 1.08190614 1.65985042 rowthree -1.52667891 -0.50032166 2.04588634 -1.55943514 1.58400939 -0.03039314 -0.21145199 0.11526848 2.24376313 -0.74787863 rowfour 0.39287271 -0.55125576 -0.74755340 -1.73366333 0.18886435  0.60942387 1.03573198 -1.93694305 0.32919872 -0.09073655
>

t2<-as.table(matrix(rnorm(40),nrow=4,ncol=10));rownames(t1)<-c("rowone","rowtwo","rowthree","rowfour")
> t2
            A           B           C           D           E           F
        G           H           I           J
A -0.23533769 -1.13888448 0.33531402 0.53159432 0.37499285 0.14237453  0.38195561 -1.06769856 -0.43285636 0.50321651 B -1.96015770 -0.70381431 0.24031069 -0.65790501 -0.87634039 0.26629589  0.66948553 -0.78660318 0.86132576 -1.03440605 C 1.48375673 -0.07710868 -0.18416378 -2.39868210 -0.09285612 0.88384443  1.34379990 1.15250558 -1.26557860 -0.63810608 D -1.45636216 0.03015655 1.68455454 1.19187925 0.10197788 0.54773000 -0.19173498 0.74170610 1.10240139 1.32562483

How can t1 and t2 be combined in an object with dim(object)=c(2,4,10)? Thank you and wishing you a great day!
Georg.



Georg B. Ehret
Johns Hopkins
Baltimore, USA

        [[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 23 Apr 2008 - 20:56:25 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 23 Apr 2008 - 23:30:30 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