Skip to content

Non-repeated and non-duplicated combinations from groups with varying sizes that contain overlaps #50

Description

@delt87

Is it possible to achieve the results below using either comboGeneral or comboGroups? (I'm not sure which one is the right function based on the few attempts I've made so far). I would like the end result to have no repetitions and duplications from any of the sets. Using expand.grid is too slow as I have to manually adjust for repetitions and duplications and I would also like to take advantage of the FUN argument in your library to do some other things to the result. Thank you for this great library!

  set1 <- c("Paul G","Mike B","Steph D","Ron B","Ryan R")
  set2 <- c("Ron B","Ryan R","Matt B","Joe D")
  set3 <- c("Ryan R","Steven Z","Dennis D","Mike A")
  set4 <- c("Mike A","Steven Z","Luka E","Francis B","Tom A")
  set5 <- c("Ross U","Bobby A","Max Z","Flori A")
  
  all_combos <- expand.grid(set1, set1, set2, set2, set3, set3, set4, set4, set5)
  all_combos <- all_combos[1:25000,]
  all_combos <- all_combos[!duplicated(t(apply(all_combos, 1, sort))), ]
  all_combos$dups <- apply(all_combos, 1, function(i) any(duplicated(i[!is.na(i)])))
  all_combos <- all_combos[all_combos$dups==FALSE,][,-c(10)]

>   all_combos[1:2,]
        Var1   Var2   Var3  Var4     Var5   Var6     Var7   Var8   Var9
7252  Mike B Paul G Matt B Ron B Dennis D Ryan R Steven Z Mike A Ross U
7253 Steph D Paul G Matt B Ron B Dennis D Ryan R Steven Z Mike A Ross U

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions