So I am currently using the following code to generate my combinations:
combn(x,y)
But the thing is that function stores all of the possible combinations. I dont want to store them, I just want to produce them through like a loop or something. It would be way more efficient for my program. Is there a way to generate combinations through a for loop rather than storing them all?
I know I asked a similar question here: How do I find all possible subsets of a set iteratively in R?
But in that solution the combinations are still being stored...
Here is some more detail:
Lets say I want to find 4 choose 2. combn(4,2) would essentially store the following: ((1,4),(1,3),(1,2),(2,4),(2,3)(3,4))
What I want is this:
loop{
produces one combination at a time
}