Is there an easy way to mask (or flag) data values in R so they do not get processed. I am using predict.randomForest on a satellite image and there are a lot (~30%) of pixels with a value of "0" that I'd prefer not to process with predict.randomForest to save time. I was thinking it might be possible to create a data frame with valid data for each line read from the input multi-band image and then reconstruct the line before writing it out but I think the overhead would be very high. At least using the brute force methods like rbind. All the best, Ned
Using a mask
2 messages · Ned Horning, Roger Bivand
On Fri, 27 Feb 2009, Ned Horning wrote:
Is there an easy way to mask (or flag) data values in R so they do not get processed. I am using predict.randomForest on a satellite image and there are a lot (~30%) of pixels with a value of "0" that I'd prefer not to process with predict.randomForest to save time. I was thinking it might be possible to create a data frame with valid data for each line read from the input multi-band image and then reconstruct the line before writing it out but I think the overhead would be very high. At least using the brute force methods like rbind.
It looks as though setting the values to NA will work. In the predict.randomForest example, do: df <- iris[ind == 2,] is.na(df[1:10, 1:2]) <- TRUE predict(iris.rf, df) So setting the 0 values to NA might get you the results you want, maintaining the relative order of the observations. Roger
All the best, Ned
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no