[R] all combinations with replacement

From: Kehl Dániel <kehld_at_ktk.pte.hu>
Date: Thu, 21 Apr 2011 12:28:41 -0700


Dear all,

is there an easy way to get all possible combinations (?) with replacement. If n=6, k=3, i want something like

0 0 6
0 5 1
0 4 2
0 3 3
0 2 4
.
.
.

5 0 1
5 1 0
6 0 0

I tried to look at combn() but I could not get this done with it.

Thank you in advance:
Daniel



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. Received on Thu 21 Apr 2011 - 19:30:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Apr 2011 - 14:50:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive