Try this:

do.call(rbind,
          apply(combn(names(x), 2),
                  2,
                  function(n)expand.grid(x[,n[1]], x[,n[2]])))

On Wed, Jun 10, 2009 at 11:47 AM, Moumita Das
<das.moumita.online@gmail.com>wrote:

> Hi friends,
> Please can anyone help me with an easier solution of doing the  below
> mentioned work.
> Suppose i have a dataset like this:---
>
> i1 i2  i3   i4 i5
> 1  7  13  1  2
> 2  8  14  2  2
> 3  9  15  3  3
> 4  10 16  4  4
> 5  11 17  5  5
> 6  12 18  6  7
>
>
> *i1,i2,i3,i4,i5 are my items.I am able to find all possible pairs i.e
> Say this dataframe is "item_pairs"
> **i1,i2
> **i1,i3
> **i1,i4
> i1,i5
> **i2,i1
> **i2,i3
> i2,i4
> i2,i5
> **i3,i1
> **i3,i2
> **i3,i4
> **i3,i5
> **i4,i1
> **i4,i2
> **i4,i3
> i4,i5
> i5,i1
> i5,i2
> i5,i3
> i5,i4
>
> Pairs like (i1,i1) or (i2,i2) are not required.Now pair (i1,i2) is same as
> pair (i2,i1) .How can i chop off the second pair which is identicle to the
> first one,only that sequence of item numbers are different ,otherwise my
> dataset is same.
>
> I thought of something...like ....running loops for all rows and columns of
> this item_pairs dataframe and check if first item in a pair matches with
> any
> second item of previous pair and similarly  **second item in a pair matches
> with any first item of previous pair* and keep entering them in a dataframe
> and get the unique pairs.
>
> But is there any other easier way of chopping off the identicle pairs?
> *-- *
> Thanks in advance
> Moumita
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


