I have 5 items each of which can take on the value of 1 or -1. I want to generate a matrix that consists of rows of the possible combinations. The order of the items does no
Alternative from data.table package is slightly faster compared to expand.grid:
data.table
expand.grid
library(data.table) CJ(c(-1,1), c(-1,1), c(-1,1), c(-1,1), c(-1,1))