But is there a way to construct a S4 method with this syntax : 0 < C < 1 ? Apparently, it's not possible with S4 group generics "Compare(e1, e2)".
2008/8/12 Ravi Varadhan <[EMAIL PROTECTED]> > Here is how you check whether a < x < b "without" using the `&' condition: > > is.between <- function(x, a, b) { > (x - a) * (b - x) > 0 > } > > Ravi. > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On > Behalf Of Shubha Vishwanath Karanth > Sent: Tuesday, August 12, 2008 9:46 AM > To: Ravi Varadhan; Dan Davison; Ravi Varadhan; Dan Davison; Ravi Varadhan; > Dan Davison; Ravi Varadhan; Dan Davison > Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: Re: [R] Between the values > > Thanks Ravi... But was just wondering if there existed a simple tricky > command for that without using the & condition.... > > Also was thinking on my second question that how do we define an interval > between 0 and 1 which contains all the values between 0 and 1. > > Thanks, Shubha > Shubha Karanth | Amba Research > Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * > New York * San José * Singapore * www.ambaresearch.com > > > -----Original Message----- > From: Ravi Varadhan [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 12, 2008 7:12 PM > To: Shubha Vishwanath Karanth; 'Dan Davison' > Cc: [EMAIL PROTECTED] > Subject: RE: [R] Between the values > > > Hi Shubaa, > > Here is one way to do this: > > is.between <- function(x, a, b) { > x > a & x < b > } > > set.seed(123) > > x <- rnorm(5) > > is.between(x, -1, 1) > > > is.between(x, -1, 1) > [1] TRUE TRUE FALSE TRUE TRUE > > > > > Ravi. > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On > Behalf Of Shubha Vishwanath Karanth > Sent: Tuesday, August 12, 2008 9:25 AM > To: Dan Davison > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Between the values > > Or at least anyways of defining a vector/(or something like that) which has > all values between 0 and 1? > > For example: > C(0,1) is incorrect, seq(0,1,0.2) is also incorrect, seq(0,1,0.00001) is > also incorrect.... How does one specify this? > > Thanks, Shubha > > > -----Original Message----- > From: Dan Davison [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 12, 2008 5:54 PM > To: Shubha Vishwanath Karanth > Cc: [EMAIL PROTECTED] > Subject: Re: [R] Between the values > > On Tue, Aug 12, 2008 at 05:16:01PM +0530, Shubha Vishwanath Karanth > wrote: > > Hi R, > > > > > > > > This is a very trivial one.... > > > > > > > > C=0.1 > > > > > > > > I want to check whether my value of C is between 0 and 1 > exclusively.... > > I don't want to use (C>0 & C<1). And I can't use a single statement > like > > (0<C<1). Is there a between function? Or how do we specify from 0 to > 1? > > Does %in% help me? > > If you don't like (C > 0 && C < 1), then just write your own function > is.between(x, low, high) (NB1 you've basically written it already; NB2 > single '&' for the vectorised version 'are.between'). People's personal > tastes about what's desirable will vary, and anyway it's good practice to > build up your own personal library of functions. Ultimately if you have a > high quality collection of related functions for working on a particular > sort of problem, then you should publish them as an R package on CRAN. > > Dan > > > > > > > > > > > > > Many Thanks, > > > > Shubha > > > > > > > > This e-mail may contain confidential and/or privileged > i...{{dropped:13}} > > > > ______________________________________________ > > 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. > > -- > www.stats.ox.ac.uk/~davison <http://www.stats.ox.ac.uk/%7Edavison> > This e-mail may contain confidential and/or privileged i...{{dropped:10}} > > ______________________________________________ > 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. > This e-mail may contain confidential and/or privileged i...{{dropped:10}} > > ______________________________________________ > 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. > > ______________________________________________ > 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. > [[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.