I am trying to make a table that has every combination of 1 and 0, in lists of 5. For example,
11111
11110
10111
10011,
and so on. The order does matter. I am trying to do it in Excel currently but all the videos I am watching on the topic are using Power Query or another way that my Excel seems to be missing.
Is there a simple way to do this in Excel or even R? I have some R experience but would prefer it to be in Excel. Thanks so much for any guidance!
>Solution :
What you’re describing could be thought of as "all the 5 digit numbers in binary", which can describe the integers from 0 to 31. There’s a built-in function in one of the packages that comes with R (R.utils) that converts from integer to binary. So:
R.utils::intToBin(0:31)
Result
[1] "00000" "00001" "00010" "00011" "00100" "00101" "00110" "00111" "01000" "01001" "01010" "01011" "01100"
[14] "01101" "01110" "01111" "10000" "10001" "10010" "10011" "10100" "10101" "10110" "10111" "11000" "11001"
[27] "11010" "11011" "11100" "11101" "11110" "11111"
In Excel, make a column with the numbers from 0 to 31. Then next to that, put in DEC2BIN(A1,5) and drag down.
