If I understand the question correctly
b <- matrix(data =
c('AA','GG','AA','GG','TT','AA',
'AA','GG','GG','GG','GG','GG',
'TT','TT','AA','TT','GG','GG',
'CC','CC','CC','TT','TT','AA',
'AA','CC','AA','CC','AA','GG',
'AA','TT','CC','CC','TT','CC'),
nrow = 6)
colnames(b) <- paste0('v',1:6)
the_min <- c('AA', 'GG', 'GG', 'CC', 'AA', 'CC')
the_max <- c('TT','AA','AA','AA','GG','AA')
b
#> v1 v2 v3 v4 v5 v6
#> [1,] "AA" "AA" "TT" "CC" "AA" "AA"
#> [2,] "GG" "GG" "TT" "CC" "CC" "TT"
#> [3,] "AA" "GG" "AA" "CC" "AA" "CC"
#> [4,] "GG" "GG" "TT" "TT" "CC" "CC"
#> [5,] "TT" "GG" "GG" "TT" "AA" "TT"
#> [6,] "AA" "GG" "GG" "AA" "GG" "CC"
the_min
#> [1] "AA" "GG" "GG" "CC" "AA" "CC"
the_max
#> [1] "TT" "AA" "AA" "AA" "GG" "AA"
is_min <- function(x) b[x,] == the_min[x]
is_min(1)
#> v1 v2 v3 v4 v5 v6
#> TRUE TRUE FALSE FALSE TRUE TRUE
is_max <- function(x) b[x,] == the_max[x]
is_max(1)
#> v1 v2 v3 v4 v5 v6
#> FALSE FALSE TRUE FALSE FALSE FALSE
holder <- matrix(nrow = 6, ncol = 6)
for(i in 1:6) holder[i,] = is_min(i) * 1
the_mins <- holder
holder
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 1 1 0 0 1 1
#> [2,] 1 1 0 0 0 0
#> [3,] 0 1 0 0 0 0
#> [4,] 0 0 0 0 1 1
#> [5,] 0 0 0 0 1 0
#> [6,] 0 0 0 0 0 1
holder <- matrix(nrow = 6, ncol = 6)
for(i in 1:6) holder[i,] = is_max(i) * 1
the_maxs <- holder
holder
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 0 0 1 0 0 0
#> [2,] 0 0 0 0 0 0
#> [3,] 1 0 1 0 1 0
#> [4,] 0 0 0 0 0 0
#> [5,] 0 1 1 0 0 0
#> [6,] 1 0 0 1 0 0
Created on 2022-11-18 by the reprex package (v2.0.1)
If not or if my outline is unclear, please let me know.