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,
A data.frame solution:
if(!require(plyr)){ install.packages("plyr")} rm.neg<-colwise(function(x){ return(ifelse(x < 0.1, 0, x))}) rm.neg(data.frame(mat))
PS: the code for rm.neg can be extracted and simplified so as not to need a call to plyr, which is used to create the colwise function.