I have this piece of code in Matlab which I believe is replacing netcdf fill values with Matlab fill values. How do I convert this code into R ? I am using netcdf4
inp.COAST_RLON.data ( inp.COAST_RLON.data< -900 ) = NaN;
inp.COAST_RLAT.data ( inp.COAST_RLAT.data< -900 ) = NaN;
If you have an R vector, matrix, or array and wish to replace values matching a criterion with another value, you do:
So your criterion is
foo < -900
and your replacement isNA
.So whatever you read from
netcdf
files as vectors, matrices, or arrays can be fixed:I'm not totally familiar with what
ncvar_get
returns but I think its a vector, matrix, or array.