[R] Combination that adds a value

From: Julio Rojas <jcredberry_at_ymail.com>
Date: Mon, 21 Mar 2011 04:08:50 -0700 (PDT)


Dear all, I have three vectors "x<-1:n", "y<-1:m" and "z<-2:(n+m)". I need to find all combinations of "x" and "y" that add up a given value of "z", e.g., for "z==3" the combinations will be "list(c(1,2),c(2,1))".

Thanks in advance for your help.



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 Mon 21 Mar 2011 - 11:12:34 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 Tue 22 Mar 2011 - 14:40:24 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