Skip to content
Prev 66468 / 398503 Next

replace values in a matrix subject to boolean condition

Werner Wernersen wrote:

            
Two ways to interpret your question:

1) if col5 < 100 replace col5 & col6 & col7 & col8 by 0:

    X[X[,5] < 1000, 5:8] <- 0


2) if col5 < 100 replace col5 by 0, if col6 < 100 replace col6 by 0, ...:


for(i in 5:8)
    X[X[,i] < 1000, i] <- 0

Uwe Ligges