Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Making a table that has all possible combinations

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading