Q:

Combination help on algorithm to create augmented factorial design

I am trying to create an algorithm that will create all possible combinations of adding two runs in a 2^k factorial design. I have seen many example of combination out there but none of them really address this specific problem. The result of this algorithm should be a matrix of k number of columns and (2^k choose 1) + (2^k choose 2) + 1  number of rows to give the correct number of 2 combinations. So for a 2^2 design we will have 2 columns and 11 rows (4 + 6 + 1) I designed this matrix below just to show how it should look like. Where each pair of rows (1,2) (2,3) (3,4) etc is  supposed to be different different (I know it isn't right now ). This does not need to be super efficient or in a specific language but would prefer R, I just need to figure out what kind of approach can be used to do this
Run   A   B
 1   -1  -1
 2   -1  -1
 3    1  -1
 4    1  -1
 5   -1   1
 6   -1   1
 7    1   1
 8    1   1
 9   -1  -1
10   -1   1
11    1   1

A:

So after trying to do this in the most effective ways (Only one more row than the total number of combinations) and failing. I decided to go with an approach that will produce all the combinations in the format where rows (1&2),(3&4), etc are two different combinations. Here is the code in R if anyone is interested
numFactors <- 2
org <- gen.factorial(2,numFactors)
orgRow <- nrow(org)
x <- c(seq(1,orgRow))
z <- (x*2)
numARow <- sum(z) ##Double the total combinations
aug <- matrix(data = NA, nrow = numARow, ncol = numFactors)
j <- 1
k <- 1
output <- list()
for (i in 1:(numARow/2)) { ##This wil create all possible 2 combinations in the style of 1&2,3&4...
  l <- (2*i) - 1  ## 1, 3, 5 ....
  first <- org[j,]
  if (k != j) {
    second <- org[k,]
    k <- k +1
  }
  if (k == j) {
    second <- org[k,]
    k <- k +1
  }
  output[[i]] <- rbind(first,second)
  if (k == (orgRow+1)) {
    j <- j + 1
    k <- j
        }
}

