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",arr.ind=TRUE)
A further point. Since "x1" was not an array, setting arr.ind=TRUE did
nothing. That flag is designed to allow return of multiple dimensional
results:
> arr <- array(1:27, c(3,3,3) )
> which(arr==9)
[1] 9
> which(arr==9, arr.ind=TRUE)
dim1 dim2 dim3
[1,] 3 3 1
x0[x2]
Thanks.
--
--
David Winsemius, MD
West Hartford, CT
______________________________________________
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.