[R] Multiple match function?
Jonathan Baron
baron at psych.upenn.edu
Wed Jun 11 03:52:12 CEST 2003
On 06/11/03 03:28, Jonck van der Kogel wrote:
>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".
one way is
which(x==2)
I'm sure there are others.
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
R page: http://finzi.psych.upenn.edu/
More information about the R-help
mailing list