Re: [R] Transforming boolean subsetting into index subsetting

2013-06-29 Thread Jim Holtman
which ( abs(V - 9) <= 3 ) Sent from my iPad On Jun 28, 2013, at 17:58, Julio Sergio wrote: > One of the techniques to subset, a vector for instance, is the following: > > V <- c(18, 8, 5, 41, 8, 7) > V > ## [1] 18 8 5 41 8 7 > ( I <- abs(V - 9) <= 3 ) > ## [1] FALSE TRUE FALSE FALSE

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread William Dunlap
r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Bert Gunter > Sent: Friday, June 28, 2013 5:01 PM > To: Julio Sergio > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Transforming boolean subsetting into index subsetting > > ?which >

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread Bert Gunter
?which -- Bert On Fri, Jun 28, 2013 at 2:58 PM, Julio Sergio wrote: > One of the techniques to subset, a vector for instance, is the following: > > V <- c(18, 8, 5, 41, 8, 7) > V > ## [1] 18 8 5 41 8 7 > ( I <- abs(V - 9) <= 3 ) > ## [1] FALSE TRUE FALSE FALSE TRUE TRUE > V[I]

Re: [R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread peter dalgaard
On Jun 28, 2013, at 23:58 , Julio Sergio wrote: > One of the techniques to subset, a vector for instance, is the following: > > V <- c(18, 8, 5, 41, 8, 7) > V > ## [1] 18 8 5 41 8 7 > ( I <- abs(V - 9) <= 3 ) > ## [1] FALSE TRUE FALSE FALSE TRUE TRUE > V[I] > ## [1] 8 8 7 > > Howe

[R] Transforming boolean subsetting into index subsetting

2013-06-28 Thread Julio Sergio
One of the techniques to subset, a vector for instance, is the following: V <- c(18, 8, 5, 41, 8, 7) V ## [1] 18 8 5 41 8 7 ( I <- abs(V - 9) <= 3 ) ## [1] FALSE TRUE FALSE FALSE TRUE TRUE V[I] ## [1] 8 8 7 However, sometimes we are interested in the indexes of the elements w