[R] combine two dataframe

Denver XU financialengine at gmail.com
Wed Nov 14 06:48:46 CET 2007


try this
x<-c(1,2,3,2,3,1,1,3,2)
A<-matrix(x,3,3,byrow=T)
B<-matrix(c(1,2,2,1),2,2)
A1<-matrix(rep(A,each=2),6,3)
B1<-rbind(B,B,B)
data.frame(A1,B1)
  X1 X2 X3 X1.1 X2.1
1  1  2  3    1    2
2  1  2  3    2    1
3  2  3  1    1    2
4  2  3  1    2    1
5  1  3  2    1    2
6  1  3  2    2    1



2007/11/13, sun <flyhyena at yahoo.com.cn>:
> I have two data frame A and B adn want to cross them.
> A has format as:
>
> a1  a2 a3
> 1   2    3
> 2   3    1
> 1   3    2
> ...
>
> B:
>
> b1 b2
> 1   2
> 2   1
> ...
>
> the combine result shall be something like
>
> a1 a2 a3 b1 b2
> 1   2   3   1  2
> 1   2   3   2  1
> 2   3   1   1  2
> 2   3   1   2  1
> 1   3   2   1  2
> 1   3   2   2  1
> ....
>
>
> is there a function able of doing this instead of  loops?
>
> Thanks,
> Sun
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list