Re: [R] remove the missing value,NA

From: Jorge Iván Vélez <jorgeivanvelez_at_gmail.com>
Date: Fri, 8 Feb 2008 14:40:33 -0500

Hi Mohamed,

May be it's not the best way, but you can try

> w=c(1,4,5,2,NA,4,5,1,NA)
> w[-which(is.na(w))]

[1] 1 4 5 2 4 5 1

I hope this helps.

Jorge

On 2/8/08, mohamed nur anisah <nuranisah_mohamed_at_yahoo.com> wrote:
>
> I have two sets of interval data.Below are my two dataset. In these
> dataset, there is a missing values in each of the data. I want to find the
> non-overlapping interval values. Here is my code:
>
> mysetdiff=function(x,y){
> m=length(x)
> n=length(y)
> bx = logical(m)
> by = logical(n)
> for(i in 1:m){
> for(j in 1:n){
> if(x[i]<=y[j]){
> bx[i] = T
> by[j] = T
> }
> }
> }
> sx = x[!bx]
> sy = y[!by]
> s=c(sx,sy)
> return(s)
> }
>
> How am i going to remove the NA value in my function?? any sugesstion??
> thanks a bunch
>
> c
> [1] 17130612 17712302 21225764 25012714 33852816 36012944 36252300
> [8] 36737468 43693832 44148616 45318876 45852632 53258208 58530988
> [15] 60437872 72516480 79673224 93128744 94269896 95868704 99651504
> [22] 113688560 131101008 132955984 135891280 141318144 148257888 156158176
> [29] 157797616 162055856 168221296 173125232 176267104 182826240 183742528
> [36] 184401728 190671888 196639616 17587118 18221688 21387314 30748348
> [43] 34480192 36209144 36280276 36971144 43878548 44496056 45740012
> [50] 46752088 53700056 58603536 60691012 72757696 80077728 93181480
> [57] 94474624 97418088 106596368 120128352 132462320 132980744 135998880
> [64] 142259520 151591840 156920960 157838176 162743136 168466848 173167936
> [71] 176338384 182930096 184149776 185735712 190910576 NA
> > d
> [1] 17712302 21203780 25012714 33852816 34794536 36012944 37891284
> [8] 43693832 44148616 45852632 53289188 61573112 63664928 72516480
> [15] 79673224 94474624 95868704 99651504 113688560 125159688 127388568
> [22] 131101008 154599216 176267104 181504912 182562720 182826240 183742528
> [29] 196841904 18100404 21387314 30748348 34384588 35996440 36252300
> [36] 37942556 43878548 44496056 46752088 53700056 62637560 63969952
> [43] 72757696 80077728 94617360 97144032 106596368 120128352 127220456
> [50] 127504536 132462320 154717312 176338384 181836032 182687824 182930096
> [57] 184149776 NA
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[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. Received on Fri 08 Feb 2008 - 19:45:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Feb 2008 - 20:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.