On Tuesday 06 December 2005 14:41, JeeBee wrote:
[...]
N = 4
input_numbers = seq((2^N)-1, 0, -1)
# convert to binary matrix
input_mat = NULL
for(i in seq(N-1,0,-1)) {
new_col = input_numbers %% 2
input_mat = cbind(new_col, input_mat)
input_numbers = (input_numbers - new_col) / 2
}
Hello,
Being new to R, I am completely stuck with the following problem. Please
help to find a general solution to the following matrix task:
Given:
N-4
input_mat-matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0,
Here is one possible solution:
for(cr in seq(1, dim(combin_mat)[2])) {
W = which(input_mat[,combin_mat[1,cr]] == 1
input_mat[,combin_mat[2,cr]] == 1)
cat(Combination, cr, (, combin_mat[,cr], ) :, W, \n)
}
JeeBee.
---
Full program:
N = 4
input_numbers = seq((2^N)-1, 0, -1)
#