[R-sig-Geo] converting 0 to NAN in SpatialGridDataFrame
Lionel Hertzog
s6lihert at uni-bonn.de
Tue Feb 5 16:24:24 CET 2013
Dear Wesley,
You can access the data components of a SpatialGridDataFrame using
@data, and then classic data frame operation can be done , in your
example this would be:
TC1.dte1 at data[TC1.dte1 at data==0]<-NA
Hope this help,
Lionel
Le 05/02/2013 16:15, Wesley Roberts a écrit :
> Dear R-sig-geo
>
> I have been searching for a way to convert 0s to NAN in R but have not had
> any luck. I have tried the following with no luck
>
> is.na(TC1.dte1)<-TC1.dte1<=0
>
> TC1.dte1[is.na(TC1.dte1)]<=0
>
> TC1.dte1[TC1.dte1==0]<-NA
>
>
> What I would like to do is to remove all 0s from TC1.dte1 and replace them
> with NA or NANs. The 0s are a mask which I dont want to alter in subsequent
> work.
>
> My data is in a SpatialGridDataFrame and was imported into R using rgdal.
>
> Many thanks for your help and inputs,
> Wesley
>
More information about the R-sig-Geo
mailing list