I have a matrix (2601 by 58) of particulate matter concentration estimates from an air quality model. Because real-life air quality monitors cannot measure below 0.1 ug/L,
Further equivalent methods:
let:
M=matrix(rnorm(10*10), 10, 10)
Brute force (educative)
for (i in 1:nrow(M)) {
for (j in 1:ncol(M)) if (M[i,j]<0.1 & !is.na(M[i,j]) ) M[i,j]=NA
}
If there are missing values (NA) in M, omitting !is.na will give errors.
Another way: using recode in package car:
library(car)
recode(M, "lo:0.099999=NA")
Can't specify a strict inequality here, so that's why there's a bunch of 9. Put more nines and it turns into 0.1. lo is a convenience of recode, which gives the minimum value (removing NAs).