Re: [R] using which to select range of values

2010-04-22 Thread Greg Snow
imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Muhammad Rahiz > Sent: Thursday, April 22, 2010 9:21 AM > To: r-help@r-project.org > Subject: [R] using which to select range of values >

Re: [R] using which to select range of values

2010-04-22 Thread David Winsemius
On Apr 22, 2010, at 11:21 AM, Muhammad Rahiz wrote: Hi all, I would like to get the array index for a range of values, say 0 < x < 1.5. I'm wondering if there is an alternative for the following which I've done x0 <- rnorm(100) x1 <- ifelse(x0 > 0 & x0 < 1.5,"t","f") x2 <- which(x1=="t"

Re: [R] using which to select range of values

2010-04-22 Thread David Winsemius
On Apr 22, 2010, at 11:39 AM, Steve Lianoglou wrote: Hi, On Thu, Apr 22, 2010 at 11:21 AM, Muhammad Rahiz wrote: Hi all, I would like to get the array index for a range of values, say 0 < x < 1.5. I'm wondering if there is an alternative for the following which I've done x0 <- rnorm(

Re: [R] using which to select range of values

2010-04-22 Thread Steve Lianoglou
Hi, On Thu, Apr 22, 2010 at 11:21 AM, Muhammad Rahiz wrote: > Hi all, > > I would like to get the array index for a range of values, say  0 < x < 1.5. > I'm wondering if there is an alternative for the following which I've done > > x0 <- rnorm(100) > x1 <- ifelse(x0 > 0 & x0 < 1.5,"t","f") > x2 <

[R] using which to select range of values

2010-04-22 Thread Muhammad Rahiz
Hi all, I would like to get the array index for a range of values, say 0 < x < 1.5. I'm wondering if there is an alternative for the following which I've done x0 <- rnorm(100) x1 <- ifelse(x0 > 0 & x0 < 1.5,"t","f") x2 <- which(x1=="t",arr.ind=TRUE) x0[x2] Thanks. -- Muhammad ___