My data is within a 96 X 12 numeric matrix. Sprinkled within the matrix are these -9999.0000 values that represent "no data". What's the most efficient way to replace these values with NA's?
Thanks
Try this:
m = matrix(sample(c(-9999.0,1:10), 10000, replace=T), ncol=100)
m[m==-9999.0] = NA
A similarly efficient way (at least with a few quick tests) is to use replace
.
The syntax would be something like:
replace(m, m == -9999, NA)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.