Marc == Marc Schwartz [EMAIL PROTECTED]
on Fri, 19 Sep 2003 16:26:12 -0500 writes:
Marc On Fri, 2003-09-19 at 15:57, Douglas Bates wrote:
DB It may be easier to use the match function which is
DB defined to return the index of the first match.
DB
DB corretor - c(15,
Since I'm sure that I have seen the not-so-good min(which(a == x)) or
which(a == x)[1] several times before, I've added a note about
this (in the SEE ALSO section) of help(which) --- still in the
optimistic assumption that people read help pages... ;-)
I had noticed the remark on the help
Damon == Damon Wischik [EMAIL PROTECTED]
on Sat, 20 Sep 2003 10:58:02 +0100 (BST) writes:
MM Since I'm sure that I have seen the not-so-good
MM min(which(a == x)) or which(a == x)[1] several times
MM before, I've added a note about this (in the SEE ALSO
MM section) of
I had noticed the remark on the help page,
eehm, hardly possible, since I've only added it today to the
development sources...
You seem to be talking about something else, but related..
Indeed, I've been confusing myself thoroughly. I thought you were
referring to the remark that is there
Hi, all. I'd like to know if exists a manner to get the first index where
a condition is attained in a vector. For example,
There is a better solution than
first.index - table(subject[corretor==27])[1]
(give me the subject for the first time that corretor is 27)?
Thanks,
Have you considered which, as in the following:
a - rep(1:2, 2)
a
[1] 1 2 1 2
which(a==1)
[1] 1 3
which(a==1)[1]
[1] 1
hope this helps. spencer graves
Cezar Augusto de Freitas Anselmo wrote:
Hi, all. I'd like to know if exists a manner to get the first index where
a condition is attained
On Fri, 2003-09-19 at 13:15, Cezar Augusto de Freitas Anselmo wrote:
Hi, all. I'd like to know if exists a manner to get the first index where
a condition is attained in a vector. For example,
There is a better solution than
first.index - table(subject[corretor==27])[1]
(give me the
It may be easier to use the match function which is defined to return
the index of the first match.
corretor - c(15, 23, 27, 34, 25, 27, 26)
match(27, corretor)
[1] 3
Marc Schwartz [EMAIL PROTECTED] writes:
On Fri, 2003-09-19 at 13:15, Cezar Augusto de Freitas Anselmo wrote:
Hi, all. I'd
On Fri, 2003-09-19 at 15:57, Douglas Bates wrote:
It may be easier to use the match function which is defined to return
the index of the first match.
corretor - c(15, 23, 27, 34, 25, 27, 26)
match(27, corretor)
[1] 3
True and presumably much faster as the size of the search vector and