Thanks guys! expand.grid looks like the thing I need.

Meanwhile, I also came up with an alternative way of doing it using rep and
cbind.

pairwise <- function(a,b) {
    aa = rep(a, each=length(b))
    cbind(aa,b)
}



On Mon, May 25, 2009 at 9:52 PM, Mike Lawrence <mike.lawre...@dal.ca> wrote:

> expand.grid(i,j)
>
> On Mon, May 25, 2009 at 8:26 PM, alad <abhimanyu...@gmail.com> wrote:
> >
> > Hi,
> >
> > I have:
> > i = c(1,2,3)
> > j = c(4,5,6)
> >
> > How do I create a matrix of all pairs?
> > i.e.
> > 1,4
> > 1,5
> > 1,6
> > 2,4
> > :
> >
> > Thanks!
> >
> >
> > --
> > View this message in context:
> http://www.nabble.com/How-to-create-all-pairs-tp23714659p23714659.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > 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.
> >
>
>
>
> --
> Mike Lawrence
> Graduate Student
> Department of Psychology
> Dalhousie University
>
> Looking to arrange a meeting? Check my public calendar:
> http://tr.im/mikes_public_calendar
>
> ~ Certainty is folly... I think. ~
>

        [[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.

Reply via email to