# between (a,b)
a <- 0
b <- 1
x <- rnorm(10)
x
unclass(cut(x, breaks=c(-Inf,a,b,Inf)))==2
-gary
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shubha Vishwanath Karanth
Sent: Tuesday, August 12, 2008 7:46 AM
To: [EMAIL PROTECTED]
Subject: [R
SQL has a between operator and via sqldf you can do this using
the built in data frame BOD as an example:
> library(sqldf)
> BOD
Time demand
118.3
22 10.3
33 19.0
44 16.0
55 15.6
67 19.8
> sqldf("select demand between 15 and 17 from BOD")
demand between 15
2008 7:34 PM
To: Shubha Vishwanath Karanth; 'Dan Davison'
Cc: [EMAIL PROTECTED]
Subject: RE: [R] Between the values
Here is how you check whether a < x < b "without" using the `&' condition:
is.between <- function(x, a, b) {
(x - a) * (b - x) > 0
}
t 12, 2008 7:21 PM
To: r-help@r-project.org
Subject: Re: [R] Between the values
Shubha Vishwanath Karanth wrote:
>
> 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
gust 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
gust 12, 2008 7:34 PM
To: Shubha Vishwanath Karanth; 'Dan Davison'
Cc: [EMAIL PROTECTED]
Subject: RE: [R] Between the values
Here is how you check whether a < x < b "without" using the `&' condition:
is.between <- function(x, a, b) {
(x - a) * (b - x) > 0
}
: 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 wond
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 trivia
'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
o:[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
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...
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
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
(0https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-proje
13 matches
Mail list logo