[R] replace NA
Joshua Wiley
jwiley.psych at gmail.com
Fri May 6 22:23:17 CEST 2011
Hi,
If your geology map is a special kind of object, this may not work,
but if you are just dealing with a data frame or matrix type object
named, "geology" with columns, something like this ought to do the
trick:
geology[is.na(geology[, "landform"]), "landform"] <- 0
?is.na returns a logical vector of TRUE/FALSE whether a value is
missing which is used to index the data and then 0 is assigned to all
those positions.
HTH,
Josh
On Fri, May 6, 2011 at 1:12 PM, azam jaafari <azamjaafari at yahoo.com> wrote:
> Hello all
>
> I have a geology map that has three level, bellow
>
> <-geology
> lithology landscape landform
>
>
> landform level is used as covariate (with codes=1,2,3,4,5) for training of neural network, but this level has missing data as NA.
> I want to replace the missing data of landform level with 0 (zero). Finally, landform will have codes 0,1,2,3,4,5.
>
> please help me
>
> Thanks alot.
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list