search for: mat_bools

Displaying 2 results from an estimated 2 matches for "mat_bools".

2024 May 03
2
Get a copy of a matrix only for TRUE entries of a matching size boolean matrix?
...of a matrix only for TRUE entries of a matching size boolean matrix? For *example*: > mat_letters <- matrix(data=c('A', 'B', 'C', 'D'), ncol=2, byrow=TRUE) > mat_letters [,1] [,2] [1,] "A" "B" [2,] "C" "D" > mat_bools <- matrix(data=c(FALSE, TRUE, TRUE, FALSE), ncol=2, byrow=TRUE) > mat_bools [,1] [,2] [1,] FALSE TRUE [2,] TRUE FALSE *Reminder:* The following is only an example ; the solution might look very different. some_command(mat_letters, mat_bools, false=empty) [,1] [,2] [1,] "&qu...
2024 May 03
1
Get a copy of a matrix only for TRUE entries of a matching size boolean matrix?
...time on it. Bonne fin de journ?e de Montr?al (nous sommes le matin ici) On Fri, May 3, 2024 at 10:30?AM Marc Girondot <marc_grt at yahoo.fr> wrote: > Is it what you want ? > mat_letters <- matrix(data=c('A', 'B', 'C', 'D'), ncol=2, byrow=TRUE) > mat_bools <- matrix(data=c(FALSE, TRUE, TRUE, FALSE), ncol=2, byrow=TRUE) > > ifelse(mat_bools, mat_letters, "") > ifelse(mat_bools, mat_letters, NA) > > > ifelse(mat_bools, mat_letters, "") > [,1] [,2] > [1,] "" "B" > [2,] "C&...