Wesley, you could read your data using the raster package. It offers memory
anagement for large rasters and I find it generally more intuitive.

library(raster)
r <- raster(TC1.dte1)

# your method
r[r == 0] <- NA
# memory safe :
r <- calc(r, function(x) ifelse(x == 0, NA, x))
r <- calc(r, function(x) {x[x==0] <- NA; x})

Etienne


2013/2/5 Wesley Roberts <jwesroberts@gmail.com>

> 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
>
> --
> Dr Wesley Roberts
> jwesroberts@gmail.com
> Cell: +27(0)83 5355 646
> skype: roberts-w
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

