Re: [R] error in the function

From: jim holtman <jholtman_at_gmail.com>
Date: Sat, 9 Feb 2008 19:09:01 -0500

a quick look at it shows you would be trying to access y[n+1] in the last part of that loop and that is greater than the number of entries in 'y' so you will get an NA and this is not legal for comparisons.

On Feb 9, 2008 6:07 PM, mohamed nur anisah <nuranisah_mohamed_at_yahoo.com> wrote:
> Dear lists,
>
> i want to find the non-overlapping interval values with this 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+1]){
> bx[i] = T
> by[j] = T
> NA = NA
> }
> }
> }
> sx = x[!bx]
> sy = y[!by]
> s=c(sx,sy)
> return(s)
> }
>
> Below is my dataset. When i called back my function with the code;>mysetdiff(f,e). An error had occur: Error in if (x[i] <= y[j + 1]) { : missing value where TRUE/FALSE needed. How am i going to fix my function so that i can get the values of my non-overlapping interval. Any suggestion?? Thanks a bunch!!
>
> e
> [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
> > f
> [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
>
>
>
>
> ---------------------------------
>
> [[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.
>

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

What is the problem you are trying to solve?

______________________________________________
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 Sun 10 Feb 2008 - 00:13:13 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 Sun 10 Feb 2008 - 00:30:13 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.

list of date sections of archive