sq function

Build matrix of binary vectors of a fixed lenght

Build matrix of binary vectors of a fixed lenght

It creates all possible binary (with elements equal to 0 or 1) vectors of a specified length; these vectors are casted in a matrix having a number of columns equal to the vector length. If required, the binary vectors are constrained to have the same total (sum of their elements).

sq(J, t = NULL)

Arguments

  • J: legnth of binary vectors
  • t: possible fixed total

Returns

  • M: matrix containing all binary vectors

Author(s)

Francesco Bartolucci, Antonio Forcina

Examples

# build matrix of all possible binary vectors of legnth 5 M = sq(5) # build matrix of all possible binary vectors of legnth 5 with total equal 2 M = sq(5,2)
  • Maintainer: Francesco Bartolucci
  • License: GPL (>= 2)
  • Last published: 2025-03-22

Useful links