[R] Methods/package for working with sets and intervals

Henrik Bengtsson hb at maths.lth.se
Mon Jul 8 17:08:43 CEST 2002


Before reinventing the wheel, is there a package for working on (nice) 
sets and intervals, where one can for instance check if a set of intervals
contains a scalar, taking the union and intersection of some intervals
etc?

 Example:

   # Defining the set i = [1,2) + [3.5, 10]
   i <- c(1,2, 3.5, 10)
   attr(i, "include") <- c(TRUE, FALSE, TRUE, TRUE)

   x <- 0:12

   # Get the x's that are within the set i.
   x[contains(i, x)]  # 1 4 5 6 7 8 9 10
   
   # Defining the set j = (-Inf,2] + [10, +Inf)
   j <- c(-Inf,2, 10, +Inf)
   attr(j, "include") <- c(NA, TRUE, TRUE, NA)

   k <- intersection(i,j)
   # k = [1,2) + [10,10]

   ...


Cheers

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences 
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
+46 46 2229611 (off), +46 708 909208 (cell), +46 46 2224623 (fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/~hb/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list