Questions tagged [binary-matrix]
54 questions
0
votes
1 answer
How do I find the least hamming distance matrix from a set of matrices for a given matrix?
I have a very large set of 400x400 binary matrices M. For a given binary matrix A, how do I find the matrix B within the set M such that it has the least hamming distance from A?

Pratik Kulkarni
- 333
- 3
- 6
0
votes
2 answers
How do I make a binary matrix comparing several columns
I'm new to programming and R.
I have a data like this in columns:
C1 C2 C3 C4 C5
Apple Apple Banana Banana
Banana Orange Orange
Orange
I want to make a binary matrix comparing all the…

molybdenumt
- 23
- 5
0
votes
3 answers
How do I convert a data frame into a binary/logical matrix in R?
So I have a data frame that contains a bunch of transactions with items, kinda like this:
| 1 | 2 | 4 | 5 | 6 |
| 3 | 5 | 8 | 9 | |
| 1 | 5 | 7 | 10 | 12 |
| 7 | 8 | 10 | 15 | 17 |
I have a list of all the existing items, and now I'd like…
0
votes
1 answer
random binary matrix with restrictions
I want to create a binary 16*15 matrix with certain conditions. I use binary strings to make the matrix. I want my matrix to be as described:
-The first and last two elements of each row must be alternative.
-the sum of each row must be 8 or 7.
-in…

Sana.Nz
- 81
- 11
0
votes
1 answer
How would I get the number (the count or sum) of black pixels connected by more than 1 other black pixel in a matrix?
I am trying to get the number of 1s (black pixels) connected by more than 1 other black pixel in a binary matrix. I have a matrix...
set.seed(1234)
mat <- matrix(rbinom(30, 1, 0.5), nrow = 5)
which outputs a matrix...
[,1] [,2] [,3] [,4] [,5]…

Arron
- 25
- 7
0
votes
2 answers
How would I get the position of the first occurrence of a value 0 in a number of binary matrices in R?
I am trying to get the position of the first occurrence of a value 0 in a number of binary matrices read in through a number of csv files.
I have got the the number of 0s using...
sapply(files_to_use, function(x) sum(x == 0))
After reading in all…

Lynda
- 141
- 7
0
votes
0 answers
From scatter plot to 2D numpy array with binary entries in Python
I have two numpy array 'x' and 'y'. I get this scatter plot using 'matplotlib.pyplot.scatter(x,y)'.
Now, how can I get a matrix with binary values (1,0) that matches the scatter plot?
The matrix should be constructed as follows: if circle then 1…

enne
- 105
- 1
- 9
0
votes
1 answer
Check if it is possible to create a Binary Matrix When sum of each row and column is given?
Given sum of each row and each column in a matrix check whether a binary matrix can be created ?
Input :
The first row of input contains two numbers 1≤m,n≤100000000, the number of rows and columns of the matrix. The next row contains m numbers…

Jack
- 1
- 2
0
votes
1 answer
R - How to extract unique intersections between groups in a binary matrix?
Dear fellow Stackoverflow users,
I am a beginner in using R language for the purpose of analysing biological data and am facing a problem that I haven't been able to solve yet - maybe someone more experienced can help me out on this?
I have a…

Rose Cave
- 23
- 2
0
votes
1 answer
Restrict apriori output of rule from a binary transaction matrix to items assigned value 1
I am trying to subset such that all items on the rhs and lhs are set to 1 but this is not working. Is there some other way I can make sure my items on the LHS and RHS of rules are all '1' only? I have used the following code.
rules =…

Shraddha Avasthy
- 161
- 3
- 13
0
votes
1 answer
what is the appropriate method to cluster binary matrix
I am a beginner in clustering, and I have a binary matrix in which each student have the sessions they are enrolled in. I want to cluster students with same sessions.
clustering methods are so many and varies according to the dataset
for exemple…

Y.sarra
- 3
- 2
0
votes
1 answer
How to compute in a binary matrix in R
Here's my problem I couldn't solve it all.
Suppose that we have the following code as follows:
## A data frame named a
a <- data.frame(A = c(0,0,1,1,1), B = c(1,0,1,0,0), C = c(0,0,1,1,0), D = c(0,0,1,1,0), E = c(0,1,1,0,1))
## 1st function…

Fouzi TAKELAIT
- 343
- 1
- 3
- 12
0
votes
1 answer
How many 1x2 zeroed submatrices fits in NxN binary matrix?
How many (at most) 1x2 (or 2x1) zeroed submatrices fits in NxN binary matrix?
For:
1 0 0
0 0 0
0 1 0
result will be 3.
For:
0 0 1 0 0 1 0 0 0
0 1 0 1 0 1 0 1 1
1 0 0 1 0 1 1 0 1
0 1 1 0 1 0 1 0 0
0 0 0 0 1 0 1 1 0
1 1 1 1 0 0 1 0 0
1 0 0 1 1 1 1 1…

Piotr Jedyk
- 361
- 1
- 10
0
votes
0 answers
R generating binary matrix with no identical rows
For a matrix of M by N containing just 0 and 1, how to make no identical rows exists. For example, if N = 3 and M = 3, one solution is:
0 0 0
0 1 0
1 0 0
I know using some exhausive permutation algorithm works, but I am thinking is there any…

Bs He
- 717
- 1
- 10
- 22
0
votes
0 answers
How to transform filtered polymorphic sites (in fasta format) into binary matrix in R?
Thank you in advance for your help...
I want to create a binary matrix from filtered polymorphic sites. I have the the WGS assemblies in fasta format, one file for each isolate sequenced (131 fasta files in total).
For examples a fasta file contains…

sruby52
- 83
- 1
- 6