Hi,

I have a data frame with 18 values which are fish flows (quantity of fishes/second). Each value is associated with the name of a trap.

I would like to make a loop in order to make all the possible combinations of trap for 1 trap, 2 traps.. until 6 traps. Only unique combinations !

Ex : with 1 trap, only 18 combinations. with 2 traps, 18x18=324 combinations.. with 6 traps, 18^2 = 3401224 possible combinations...

With the corresponding values of flow for each sampling.

For the moment I have this code :

X = my date frame

sX <- list() # list of the different samples

s <- c() # already sampled samples

for (i in 1:18) {

sX[[i]] <- sample(X[!(X %in% s)], 1, replace=FALSE)

s <- c(s, sX[[i]])

}

sX <- list() # list of the different samples

s <- c() # already sampled samples

for (i in 1:324) {

sX[[i]] <- sample(X[!(X %in% s)], 2, replace=FALSE)

s <- c(s, sX[[i]])

}

.. etc until 6 traps.

And it is almost great but it does not replace the traps, while i would like R to not replace the combination of traps. For example, for a combination of 2 traps, i have only 9 combinations because R doesn't make combination with a trap already sampled.

I hope it is clear !

Thank you so much for your help.