[R] How to remove 'NA's?

jim holtman jholtman at gmail.com
Tue Sep 15 23:09:57 CEST 2009


couple of different ways depending on what you want to do with the data:

> match(c(3,4), c(3,2,1))
[1]  1 NA
> match(c(3,4), c(3,2,1), nomatch=0)
[1] 1 0
> x <- match(c(3,4), c(3,2,1))
> x[!is.na(x)]
[1] 1
>


On Tue, Sep 15, 2009 at 5:05 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> Hi,
>
>> match(c(3,4), c(3,2,1))
> [1]  1 NA
>
> The above result has 'NA' in. Is there a way to make 'match' does not
> produce any 'NA's?
>
> Regards,
> Peng
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list