> DynV Montrealer
> on Fri, 3 May 2024 10:39:10 -0400 writes:
> It's exactly what I was looking for, thanks. I'm replying
> to the whole list so others can skip this question, to not
> waste time on it.
good.
> Bonne fin de journée de Montréal (nous sommes le matin
It's exactly what I was looking for, thanks. I'm replying to the whole
list so others can skip this question, to not waste 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 wrote:
> Is it what you want ?
> mat_letters <-
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,]
In two steps:
result <- matrix(NA_character_,
nrow=nrow(mat_letters), ncol =ncol(mat_letters))
result[mat_bools] <- mat_letters[mat_bools]
On 2024-05-03 8:47 a.m., DynV Montrealer wrote:
Is there a way to get a copy of a matrix only for TRUE entries of a
matching size boolean matrix? For
Is there a way to get a copy 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),
5 matches
Mail list logo