Clarification/correction: Ex 5 isn't consistent with the other examples.... To be consistent with the other examples the resulting ranges would be something like: xa_rng = c(-100,-100) xb_rng = c(100,100) or just... xa_rng = -100 xb_rng = 100
However, my original Ex 5 would be a good solution if the s range endpoints were not included in the results per my statement: "...but in a perfect world the resulting ranges would not include the s range endpoints and would include endpoints of the x range if they were not eliminated by an s range." Sorry, for any confusion. Thanks! Ben On Fri, May 11, 2012 at 8:58 AM, Ben quant <ccqu...@gmail.com> wrote: > Hello, > > Currently I'm only coming up with brute force solutions to this issue. > Wondering if anyone knows of a better way to do this. > > The problem: I have endpoints of one x range (x_rng) and an unknown number > of s ranges (s[#]_rng) also defined by endpoints. What I want are the parts > of the x ranges that don't overlap the s ranges. The examples below > demonstrate what I mean. I'm glossing over an obvious endpoint > inclusion/exclusion issue here for simplicity, but in a perfect world the > resulting ranges would not include the s range endpoints and would include > endpoints of the x range if they were not eliminated by an s range. > > Is there some function(s) in R that would make this easy? > > Ex 1. > For: > x_rng = c(-100,100) > > s1_rng = c(-25.5,30) > s2_rng = c(0.77,10) > s3_rng = c(25,35) > s4_rng = c(70,80.3) > s5_rng = c(90,95) > > I would get: > xa_rng = c(-100,-25.5) > xb_rng = c(35,70) > xc_rng = c(80.3,90) > xd_rng = c(95,100) > > Ex 2. > For: > x_rng = c(-50.5,100) > > s1_rng = c(-75.3,30) > > I would get: > xa_rng = c(30,100) > > Ex 3. > For: > x_rng = c(-75.3,30) > > s1_rng = c(-50.5,100) > > I would get: > xa_rng = c(-75.3,-50.5) > > Ex 4. > For: > x_rng = c(-100,100) > > s1_rng = c(-105,105) > > I would get something like: > xa_rng = c(NA,NA) > or... > xa_rng = NA > > Ex 5. > For: > x_rng = c(-100,100) > > s1_rng = c(-100,100) > > I would get something like: > xa_rng = c(NA,NA) > or... > xa_rng = NA > > > [[alternative HTML version deleted]] ______________________________________________ R-help@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.