Thank you for the quick answer, but i was asking if some method could do combinations where numbers of the same vector wont combine. A little bit like 'expand.grid', but with the possibility to choose the length for output combinations.
Cláudio 2010/4/23 Jorge Ivan Velez <jorgeivanve...@gmail.com> > Hi Cláudio, > > Try this: > > require(gtools) > combinations(10, 2) > combinations(10, 2, repeats = TRUE) > > HTH, > Jorge > > > 2010/4/23 Cláudio Sá <> > >> Hi! >> >> Is there any easy/fast way to combine vectors with restrictions? >> >> Example: >> >> a=c(1,2,3), b=c(4,5,6), c=c(7,8,9) >> >> I want all combinations of this 3 vectors with length=2. >> >> Like this: >> 1,4 >> 1,5 >> 1,6 >> 1,7 >> 1,8 >> 1,9 >> 2,4 >> 2,5 >> 2,6 >> 2,7 >> ... and so on. >> >> Thanks in advance. >> >> [[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. >> > > [[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.