[R] extracting elements by using logical values

From: mohamed nur anisah <nuranisah_mohamed_at_yahoo.com>
Date: Sun, 17 Feb 2008 13:56:25 -0800 (PST)


dear lists,    

  My question is quite simple but i'm a new user in R and it's seem tough to me. How am i going to recall back my values??ok..it could be easy if i ilustrate my problem with the simple example. say that,    x
[1] 1 2

y
[1] 2 3
   

  and my logical output from my function are (Below is my function):    

  overlapped(x,y)
[1] TRUE
[1] TRUE
  suppose i want my output to be:
  [1] 1 2
[1] 2 3
       

  overlapped<-function(x,y){
z<-rbind(x,y)
 for(i in 1:nrow(z)){
  overlap<-(z[i,1]<=z[,2]&z[i,2]>=z[,1])[-i]    if(any(overlap)) print(TRUE)
   else print(FALSE)

      }
   }

  Thanks in advance!!    

  cheers,
  Anisah                 


        [[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 Sun 17 Feb 2008 - 22:00:48 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 17 Feb 2008 - 23:30:14 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