Re: [R] writing a simple function

From: Ben Bolker <bolker_at_ufl.edu>
Date: Wed, 13 Feb 2008 15:01:38 +0000 (UTC)

Roland Rau <roland.rproject <at> gmail.com> writes:

>
> does this do what you want?
>
> overlap <- function(a,b,c,d) {
> all(c:d %in% a:b)
> }
> overlap(1,5,3,4)
> overlap(1,2,3,4)

  Do you really want this to be discrete? How about

overlap <- function(a,b,c,d) {

   a<c && b>d
}

(although this assumes that a<b and c<d ...)



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 Wed 13 Feb 2008 - 15:12:14 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 Wed 13 Feb 2008 - 18: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