?combn
> combn(10,2)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
[,13] [,14] [,15] [,16] [,17]
[1,] 1 1 1 1 1 1 1 1 1 2 2 2
2 2 2 2 2
[2,] 2 3 4 5 6 7 8 9 10 3 4 5
6 7 8 9 10
[,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27] [,28]
[,29] [,30] [,31] [,32] [,33]
[1,] 3 3 3 3 3 3 3 4 4 4 4
4 4 5 5 5
[2,] 4 5 6 7 8 9 10 5 6 7 8
9 10 6 7 8
[,34] [,35] [,36] [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45]
[1,] 5 5 6 6 6 6 7 7 7 8 8 9
[2,] 9 10 7 8 9 10 8 9 10 9 10 10
On Sat, Jul 11, 2009 at 9:23 AM, Hesen Peng<hesen.peng at emory.edu>
wrote:> Hello my R buddies,
>
> I'm trying to generate a bivariate data.frame with the elements of
> first row greater than the second row. The more complicated method
> that I can think of is:
>
> ? n <- 10
> ? temp <- expand.grid(1:n,1:n)
> ? temp<-temp[temp[,1]>temp[,2],]
>
> However, I guess there must be some easier way of doing this. Besides,
> if inequality condition is applied at the very beginning, this will
> save me a lot of memory if n goes to a very large number. Is there any
> suggestions? Thanks a lot.
>
> Best wishes,
>
> --
> ??? Hesen Peng
> http://hesen.peng.googlepages.com/
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?