Re: [S] vector subscripting question

Fei Chen (fchen@stern.nyu.edu)
Thu, 25 Jun 1998 12:28:41 -0400 (EDT)


hi all,

thanks for all these quick response. i can't believe how obvious this
should have been in hind sight. i guess i was just a little confused over
a coincidental example i had.

thanks to Z. Todd Taylor, Anne York, Larry Zaborski, Diane Liu, and
George W. Gilchris.

an example from Anne York says it all:
------------------
a <- 1:21
b <- 10:10

> a
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21
> b
[1] -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4
5 6 7 8
[20] 9 10
>
> a[b>0]
[1] 12 13 14 15 16 17 18 19 20 21

> b[b>0]
[1] 1 2 3 4 5 6 7 8 9 10
>

> a[b[b>0]]
[1] 1 2 3 4 5 6 7 8 9 10
--------------------

fei

> > i thought i had understood this, but maybe not. let's say i have two
> > vetors a and b of length 120000, should these two expressions be the same?
> >
> > 1. a[b>0]
> >
> > 2. a[b[b>0]]
> >

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news