[R] Multiple match function?
Edith Hodgen
Edith.Hodgen at nzcer.org.nz
Wed Jun 11 03:47:46 CEST 2003
?which
HTH
Edith Hodgen
Statistician and Data Manager
New Zealand Council for Educational Research
Phone: +64-4-384 7939 x 812
Fax: +64-4-384 7933
edith.hodgen at nzcer.org.nz
Web site http://www.nzcer.org.nz
>>> Jonck van der Kogel <jonck at vanderkogel.net> 11/06/2003 13:28:38 >>>
Hi all,
I have (yet another) question about a function in R. What I would like
to do is test for the presence of a certain value in a vector, and have
the positions that this value is at returned to me.
For example, let's say I have a vector:
x <- c(1,1,2,2,3,3,4,4)
Now I would like a function that would return positions 3 and 4 should
I test for the value "2". Or 5 and 6 should I test for "3".
Could someone please tell me how I should do this? The "match" function
only returns the first position that a value is found at. Of course I
could write my own function that loops through the vector and tests for
the presence of each value manually but it seems likely that a function
that does this is already present in R. No need to re-invent the wheel
:-)
Thanks very much, Jonck
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list