[R] Combination that adds a value

Julio Rojas jcredberry at ymail.com
Mon Mar 21 12:08:50 CET 2011


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.






More information about the R-help mailing list