Permutations of permutations


I have the following code creating all "paths" from and to a to g and g to a which gives us 42 permutations.

x <- c(

df_permutations <- gtools::permutations(n = length(x),
                                        r = 2,
                                        v = x,
                                        set = TRUE,
                                        repeats.allowed = FALSE) %>%

names(df_permutations) <- c("source","target")

I now want to create permutations that vary where 2 or more permutations are selected from the created set df_permutations and all those are then listed or saved into a list object (whatever works easiest).

Thus, I should have a run where only a to b is on and one where all 42 are also selected etc. I can't seem to put in a varying value for "r" unless I loop and add it together. Is this the best way of going about this?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.